Test a call to consume_order() under normal circumstances.
Test that a call to consume_order() calls order_prep.preparation.prepare_order() with the order passed to it. As prepare_order() is successful (i.e. it does not raise an exception), no critical-level logging should occur, and the message should be acknowledged.
Test a call to consume_order() where order processing fails.
Test that a call to consume_order() logs a critical-level message but does not itself raise an exception when order_prep.preparation.prepare_order() fails (i.e. raises an exception). The message should not be acknowledged.
Assert all keys but order_lines unchanged in before and after.
Test add_completion_stages adds completion stages as expected.
This breaks down in to two parts:
Test normalise_lines splits order lines as expected.
This breaks down in to two parts:
Test prepare_order normalises lines before adding completion stages.
Also tests that prepare_order never modifies any keys in the given order but order_lines.
Test get_producer() uses Kombu appropriately.
Test that publish_order() publishes given order.
Test connect_consumer() uses settings to connect to queue.
Test that runloop() repeatedly consumes from the connection.
This is done using the order_prep.tests.unit.tools.StatefulSideEffect class to check that the connection returned by connect_consumer() is called an appropriate number of times before an exception is raised.
Test that equivalent before and after pass.
Test that different before and after fail.
Test that different order_lines pass.
A class that raises an exception after n calls of side_effect().
This should be used with Mock like this:
Mock(side_effect=StatefulSideEffect(7).side_effect)
Parameters:
- call_count
- The call on which the StatefulSideEffectException should be raised (i.e. side_effect() will have been called call_count times when the StatefulSideEffectException is raised).
The method to pass to the Mock.
The exception used by StatefulSideEffect.
Assert mock called once with expected args/kwargs.
Assert mock called once with expected_args and no keywords.
Asserts mock called once with kwargs only.
Test that order_prep processes good input properly.
Currently, the order preparation service should pass through all input unmodified.
This is tested by passing example input in to order_prep.consumer.consume_order() and checking that order_prep.publisher.publish_order() calls kombu.messaging.Producer.publish() with the same input.