示例#1
0
    def test_commerce_order_detail(self):
        with mock_get_orders():
            order_detail = get_user_orders(self.user)

        user_order = mock_get_orders.default_response['results'][0]
        expected = [
            {
                'number': user_order['number'],
                'price': user_order['total_excl_tax'],
                'title': user_order['lines'][0]['title'],
                'order_date': 'Jan 01, 2016',
                'receipt_url': '/commerce/checkout/receipt/?orderNum=' + user_order['number']
            }
        ]
        self.assertEqual(order_detail, expected)
示例#2
0
    def test_commerce_order_detail(self):
        with mock_get_orders():
            order_detail = get_user_orders(self.user)

        user_order = mock_get_orders.default_response['results'][0]
        expected = [
            {
                'number': user_order['number'],
                'price': user_order['total_excl_tax'],
                'title': user_order['lines'][0]['title'],
                'order_date': 'Jan 01, 2016',
                'receipt_url': '/commerce/checkout/receipt/?orderNum=' + user_order['number']
            }
        ]
        self.assertEqual(order_detail, expected)
示例#3
0
    def test_commerce_order_detail(self):
        """
        Verify that get_user_orders returns the correct order data.
        """
        with mock_get_orders():
            order_detail = get_user_orders(self.user)

        for i, order in enumerate(mock_get_orders.default_response['results']):
            expected = {
                'number': order['number'],
                'price': order['total_excl_tax'],
                'order_date': 'Jan 01, 2016',
                'receipt_url': '/checkout/receipt/?order_number=' + order['number'],
                'lines': order['lines'],
            }
            self.assertEqual(order_detail[i], expected)
示例#4
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, [])
示例#5
0
    def test_commerce_order_detail(self):
        """
        Verify that get_user_orders returns the correct order data.
        """
        with mock_get_orders():
            order_detail = get_user_orders(self.user)

        for i, order in enumerate(mock_get_orders.default_response['results']):
            expected = {
                'number': order['number'],
                'price': order['total_excl_tax'],
                'order_date': 'Jan 01, 2016',
                'receipt_url': '/checkout/receipt/?order_number=' + order['number'],
                'lines': order['lines'],
            }
            self.assertEqual(order_detail[i], expected)
示例#6
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, [])
示例#7
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, [])
示例#8
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)
示例#9
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'], '')
示例#10
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, [])
示例#11
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)
示例#12
0
    def test_commerce_order_detail_exception(self):
        with mock_get_orders(exception=exceptions.HttpNotFoundError):
            order_detail = get_user_orders(self.user)

        self.assertEqual(order_detail, [])
示例#13
0
    def test_commerce_order_detail_exception(self):
        with mock_get_orders(exception=exceptions.HttpNotFoundError):
            order_detail = get_user_orders(self.user)

        self.assertEqual(order_detail, [])