Пример #1
0
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/'
Пример #2
0
    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, [])
Пример #3
0
    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, [])
Пример #4
0
    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)
Пример #5
0
    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'], '')
Пример #6
0
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/'