Beispiel #1
0
    def test_wait_exception_before_wait(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        exc = ExampleError()

        event.send_exception(exc)
        with pytest.raises(ExampleError):
            event.wait()
        assert not queue_consumer.get_message.called
Beispiel #2
0
    def test_wait_queue_consumer_disconnected(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        queue_consumer.connection.connected = False

        with pytest.raises(RuntimeError) as raised:
            event.wait()
        assert "disconnected" in str(raised.value)
        assert not queue_consumer.get_message.called
Beispiel #3
0
    def test_wait_queue_consumer_disconnected(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        queue_consumer.connection.connected = False

        with pytest.raises(RuntimeError) as raised:
            event.wait()
        assert "disconnected" in str(raised.value)
        assert not queue_consumer.get_message.called
Beispiel #4
0
    def test_wait(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        result = "result"

        def get_message(correlation_id):
            event.send(result)
        queue_consumer.get_message.side_effect = get_message

        assert event.wait() == result
        assert queue_consumer.get_message.call_args == call(correlation_id)
Beispiel #5
0
    def test_wait(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        result = "result"

        def get_message(correlation_id):
            event.send(result)
        queue_consumer.get_message.side_effect = get_message

        assert event.wait() == result
        assert queue_consumer.get_message.call_args == call(correlation_id)
Beispiel #6
0
    def test_wait_exception_while_waiting(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        exc = ExampleError()

        def get_message(correlation_id):
            event.send_exception(exc)
        queue_consumer.get_message.side_effect = get_message

        with pytest.raises(ExampleError):
            event.wait()
        assert queue_consumer.get_message.call_args == call(correlation_id)
Beispiel #7
0
    def test_wait_exception_while_waiting(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        exc = ExampleError()

        def get_message(correlation_id):
            event.send_exception(exc)
        queue_consumer.get_message.side_effect = get_message

        with pytest.raises(ExampleError):
            event.wait()
        assert queue_consumer.get_message.call_args == call(correlation_id)
Beispiel #8
0
    def test_wait_exception_before_wait(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        exc = ExampleError()

        event.send_exception(exc)
        with pytest.raises(ExampleError):
            event.wait()
        assert not queue_consumer.get_message.called
Beispiel #9
0
    def test_wait_already_disconnected(self, queue_consumer):
        correlation_id = 1
        event = ConsumeEvent(queue_consumer, correlation_id)

        exc = RpcConnectionError()

        event.send_exception(exc)
        with pytest.raises(RpcConnectionError):
            event.wait()
        assert not queue_consumer.get_message.called