(self)
| 671 | cont.stop(c) |
| 672 | |
| 673 | def test_start__loop(self): |
| 674 | |
| 675 | class _QoS: |
| 676 | prev = 3 |
| 677 | value = 4 |
| 678 | |
| 679 | def update(self): |
| 680 | self.prev = self.value |
| 681 | |
| 682 | init_callback = Mock(name='init_callback') |
| 683 | c = self.NoopConsumer(init_callback=init_callback) |
| 684 | c.qos = _QoS() |
| 685 | c.connection = Connection(self.app.conf.broker_url) |
| 686 | c.connection.get_heartbeat_interval = Mock(return_value=None) |
| 687 | c.iterations = 0 |
| 688 | |
| 689 | def raises_KeyError(*args, **kwargs): |
| 690 | c.iterations += 1 |
| 691 | if c.qos.prev != c.qos.value: |
| 692 | c.qos.update() |
| 693 | if c.iterations >= 2: |
| 694 | raise KeyError('foo') |
| 695 | |
| 696 | c.loop = raises_KeyError |
| 697 | with pytest.raises(KeyError): |
| 698 | c.start() |
| 699 | assert c.iterations == 2 |
| 700 | assert c.qos.prev == c.qos.value |
| 701 | |
| 702 | init_callback.reset_mock() |
| 703 | c = self.NoopConsumer(task_events=False, init_callback=init_callback) |
| 704 | c.qos = _QoS() |
| 705 | c.connection = Connection(self.app.conf.broker_url) |
| 706 | c.connection.get_heartbeat_interval = Mock(return_value=None) |
| 707 | c.loop = Mock(side_effect=socket.error('foo')) |
| 708 | with pytest.raises(socket.error): |
| 709 | c.start() |
| 710 | c.loop.assert_called() |
| 711 | |
| 712 | def test_reset_connection_with_no_node(self): |
| 713 | c = self.NoopConsumer() |
nothing calls this directly
no test coverage detected