Ejemplo n.º 1
0
    def test_add_order(self):
        """Tests the general adding of an order via the add_order method
        """
        order = add_order(self.request)

        self.assertEqual(order.state, SUBMITTED)
        self.assertEqual("%.2f" % order.price, "9.80")
        self.assertEqual("%.2f" % order.tax, "1.56")

        self.assertEqual(order.shipping_method.name, "Standard")
        self.assertEqual(order.shipping_price, 1.0)
        self.assertEqual("%.2f" % order.shipping_tax, "0.16")

        self.assertEqual(order.payment_method.name, "Direct Debit")
        self.assertEqual(order.payment_price, 0.0)
        self.assertEqual(order.payment_tax, 0.0)

        self.assertEqual(order.shipping_firstname, "John")
        self.assertEqual(order.shipping_lastname, "Doe")
        self.assertEqual(order.shipping_line1, "Street 42")
        self.assertEqual(order.shipping_line2, None)
        self.assertEqual(order.shipping_city, "Gotham City")
        self.assertEqual(order.shipping_code, "2342")
        self.assertEqual(order.shipping_phone, "555-111111")
        self.assertEqual(order.shipping_company_name, "Doe Ltd.")

        self.assertEqual(order.invoice_firstname, "Jane")
        self.assertEqual(order.invoice_lastname, "Doe")
        self.assertEqual(order.invoice_line1, "Street 43")
        self.assertEqual(order.invoice_line2, None)
        self.assertEqual(order.invoice_city, "Smallville")
        self.assertEqual(order.invoice_code, "2443")
        self.assertEqual(order.invoice_phone, "666-111111")
        self.assertEqual(order.invoice_company_name, "Doe Ltd.")

        # Items
        self.assertEqual(len(order.items.all()), 2)

        item = order.items.all().order_by('id')[0]
        self.assertEqual(item.product_amount, 2)
        self.assertEqual(item.product_sku, "sku-1")
        self.assertEqual(item.product_name, "Product 1")
        self.assertEqual("%.2f" % item.product_price_gross, "1.10")
        self.assertEqual("%.2f" % item.product_price_net, "0.92")
        self.assertEqual("%.2f" % item.product_tax, "0.18")

        item = order.items.all().order_by('id')[1]
        self.assertEqual(item.product_amount, 3)
        self.assertEqual(item.product_sku, "sku-2")
        self.assertEqual(item.product_name, "Product 2")
        self.assertEqual("%.2f" % item.product_price_gross, "2.20")
        self.assertEqual("%.2f" % item.product_price_net, "1.85")
        self.assertEqual("%.2f" % item.product_tax, "0.35")

        # The cart should be deleted after the order has been created
        cart = cart_utils.get_cart(self.request)
        self.assertEqual(cart, None)
Ejemplo n.º 2
0
    def test_order_discount_price(self):
        """Tests the price of the discount within an order.
        """
        order = add_order(self.request)

        for order_item in order.items.all():
            if order_item.product_name == "Summer":
                self.assertEqual("%.2f" % order_item.price_net, "-8.40")
                self.assertEqual("%.2f" % order_item.product_price_net, "-8.40")
Ejemplo n.º 3
0
    def test_add_order(self):
        """Tests the general adding of an order via the add_order method
        """
        order = add_order(self.request)

        self.assertEqual(order.state, SUBMITTED)
        self.assertEqual("%.2f" % order.price, "9.80")
        self.assertEqual("%.2f" % order.tax, "1.56")

        self.assertEqual(order.shipping_method.name, "Standard")
        self.assertEqual(order.shipping_price, 1.0)
        self.assertEqual("%.2f" % order.shipping_tax, "0.16")

        self.assertEqual(order.payment_method.name, "Direct Debit")
        self.assertEqual(order.payment_price, 0.0)
        self.assertEqual(order.payment_tax, 0.0)

        self.assertEqual(order.shipping_firstname, "John")
        self.assertEqual(order.shipping_lastname, "Doe")
        self.assertEqual(order.shipping_line1, "Street 42")
        self.assertEqual(order.shipping_line2, None)
        self.assertEqual(order.shipping_city, "Gotham City")
        self.assertEqual(order.shipping_code, "2342")
        self.assertEqual(order.shipping_phone, "555-111111")
        self.assertEqual(order.shipping_company_name, "Doe Ltd.")

        self.assertEqual(order.invoice_firstname, "Jane")
        self.assertEqual(order.invoice_lastname, "Doe")
        self.assertEqual(order.invoice_line1, "Street 43")
        self.assertEqual(order.invoice_line2, None)
        self.assertEqual(order.invoice_city, "Smallville")
        self.assertEqual(order.invoice_code, "2443")
        self.assertEqual(order.invoice_phone, "666-111111")
        self.assertEqual(order.invoice_company_name, "Doe Ltd.")

        # Items
        self.assertEqual(len(order.items.all()), 2)

        item = order.items.all().order_by('id')[0]
        self.assertEqual(item.product_amount, 2)
        self.assertEqual(item.product_sku, "sku-1")
        self.assertEqual(item.product_name, "Product 1")
        self.assertEqual("%.2f" % item.product_price_gross, "1.10")
        self.assertEqual("%.2f" % item.product_price_net, "0.92")
        self.assertEqual("%.2f" % item.product_tax, "0.18")

        item = order.items.all().order_by('id')[1]
        self.assertEqual(item.product_amount, 3)
        self.assertEqual(item.product_sku, "sku-2")
        self.assertEqual(item.product_name, "Product 2")
        self.assertEqual("%.2f" % item.product_price_gross, "2.20")
        self.assertEqual("%.2f" % item.product_price_net, "1.85")
        self.assertEqual("%.2f" % item.product_tax, "0.35")

        # The cart should be deleted after the order has been created
        cart = cart_utils.get_cart(self.request)
        self.assertEqual(cart, None)
Ejemplo n.º 4
0
    def test_order_discount_price(self):
        """Tests the price of the discount within an order.
        """
        order = add_order(self.request)

        for order_item in order.items.all():
            if order_item.product_name == "Summer":
                self.assertEqual("%.2f" % order_item.price_net, "-8.40")
                self.assertEqual("%.2f" % order_item.product_price_net,
                                 "-8.40")