February 2018
Intermediate to advanced
456 pages
9h 56m
English
The get_order_by_status function returns a list of orders given a status. There are two scenarios we have to test here:
def test_get_order_by_status(self): order = Order.objects.get_orders_by_status(Status.Received) self.assertEqual(2, len(order), msg=('There should be only 2 orders ' 'with status=Received.')) self.assertEqual('customer_001@test.com', order[0].order_customer.email)def test_get_order_by_status_with_invalid_status(self): with self.assertRaises(InvalidArgumentError): Order.objects.get_orders_by_status(1)
Simple enough. The first test we call ...
Read now
Unlock full access