class mock_get_orders(mock_ecommerce_api_endpoint): """ Mocks calls to E-Commerce API client order get method. """ default_response = { 'results': [ factories.OrderFactory(lines=[ factories.OrderLineFactory(product=factories.ProductFactory( attribute_values=[ factories.ProductAttributeFactory( name='certificate_type', value='verified') ])) ]), factories.OrderFactory(lines=[ factories.OrderLineFactory(product=factories.ProductFactory( attribute_values=[ factories.ProductAttributeFactory( name='certificate_type', value='verified') ])), factories.OrderLineFactory(product=factories.ProductFactory( attribute_values=[ factories.ProductAttributeFactory( name='certificate_type', value='verified') ])), ]), factories.OrderFactory(lines=[ factories.OrderLineFactory(product=factories.ProductFactory( product_class='Coupon')) ]), ] } method = httpretty.GET def get_path(self): return '/orders/'
def test_honor_course_order_detail(self): response = { 'results': [ factories.OrderFactory(lines=[ factories.OrderLineFactory( product=factories.ProductFactory(attribute_values=[ factories.ProductAttributeFactory( name='certificate_type', value='honor') ])) ]) ] } with mock_get_orders(response=response): order_detail = get_user_orders(self.user) self.assertEqual(order_detail, [])
def test_incomplete_order_detail(self): response = { 'results': [ factories.OrderFactory( status='Incomplete', lines=[ factories.OrderLineFactory( product=factories.ProductFactory(attribute_values=[factories.ProductAttributeFactory()]) ) ] ) ] } with mock_get_orders(response=response): order_detail = get_user_orders(self.user) self.assertEqual(order_detail, [])
def test_order_history_with_no_product(self): response = { 'results': [ factories.OrderFactory(lines=[ factories.OrderLineFactory(product=None), factories.OrderLineFactory( product=factories.ProductFactory(attribute_values=[ factories.ProductAttributeFactory( name='certificate_type', value='verified') ])) ]) ] } with mock_get_orders(response=response): order_detail = get_user_orders(self.user) self.assertEqual(len(order_detail), 1)
def test_order_history_with_coupon(self): """ Verify that get_order_details returns empty receipt_url for coupon product. """ response = { 'results': [ factories.OrderFactory( lines=[ factories.OrderLineFactory(product=factories.ProductFactory(product_class='Coupon')) ] ) ] } with mock_get_orders(response=response): order_detail = get_user_orders(self.user) self.assertEqual(order_detail[0]['receipt_url'], '')
class mock_get_orders(mock_ecommerce_api_endpoint): # pylint: disable=invalid-name """ Mocks calls to E-Commerce API client order get method. """ default_response = { 'results': [ factories.OrderFactory(lines=[ factories.OrderLineFactory(product=factories.ProductFactory( attribute_values=[ factories.ProductAttributeFactory( name='certificate_type', value='verified') ])) ]) ] } method = httpretty.GET def get_uri(self): return TEST_API_URL + '/orders/'