Пример #1
0
    def test_not_enough_stock(self):
        ShopConfigFactory()
        cart = CartFactory()

        request = self.factory.get("/shop/checkout/ingenico/")
        request.user = cart.customer.user
        request.session = {"cart": cart.id, "custID": cart.customer.id}

        response = pay_ship_info(request)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response._headers["location"],
            ("Location", "{}/cart/".format(
                getattr(settings, "SHOP_BASE", "/store"))),
        )
Пример #2
0
    def test_order_available(self):
        ShopConfigFactory()
        order = TestOrderFactory()

        request = self.factory.get("/shop/checkout/ingenico/declined/")
        request.user = order.contact.user
        request.session = {"orderID": order.id}

        response = declined(request)
        self.assertEqual(response.status_code, 200)
        self.assertIn("declined".encode("utf-8"), response.content)

        order = Order.objects.get(id=order.id)
        self.assertTrue(order.frozen)
        self.assertEqual(order.status.status.status, "Declined")
Пример #3
0
    def test_has_enough_stock(self):
        ShopConfigFactory()
        cart = CartFactory()
        # Make sure the items are in stock
        for item in cart.cartitem_set.all():
            item.product.items_in_stock = item.quantity
            item.product.save()

        request = self.factory.get("/shop/checkout/ingenico/")
        request.user = cart.customer.user
        request.session = {"cart": cart.id, "custID": cart.customer.id}

        response = pay_ship_info(request)
        self.assertEqual(response.status_code, 200)
        self.assertNotIn("Your cart is empty".encode("utf-8"),
                         response.content)
Пример #4
0
    def test_order_available(self):
        ShopConfigFactory()
        order = TestOrderFactory()

        request = self.factory.get("/shop/checkout/ingenico/accepted/")
        request.user = order.contact.user
        request.session = {"orderID": order.id}

        response = accepted(request)
        self.assertEqual(response.status_code, 200)
        self.assertIn("Accepted".encode("utf-8"), response.content)
        self.assertIn("Paid through Ingenico".encode("utf-8"), response.content)
        for item in order.orderitem_set.all():
            self.assertIn(item.product.name.encode("utf-8"), response.content)

        order = Order.objects.get(id=order.id)
        self.assertTrue(order.frozen)
        self.assertEqual(order.status.status.status, "Accepted")
        for item in order.orderitem_set.all():
            self.assertEqual(item.product.items_in_stock, 0)
            self.assertEqual(item.product.total_sold, item.quantity)
Пример #5
0
    def test_not_enough_stock(self):
        ShopConfigFactory()
        cart = CartFactory()
        order = TestOrderFactory()
        # Make all items out of stock
        for item in cart.cartitem_set.all():
            item.product.items_in_stock = 0
            item.product.save()

        request = self.factory.get("/shop/checkout/paypal/confirm/")
        request.user = order.contact.user
        request.session = {
            "cart": cart.id,
            "custID": cart.customer.id,
            "orderID": order.id,
        }

        response = confirm_info(request)
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response._headers["location"],
            ("Location", "{}/cart/".format(getattr(settings, "SHOP_BASE", "/store"))),
        )
Пример #6
0
 def test_base_url(self):
     ShopConfigFactory()
     config = Config.objects.get_current()
     self.assertEqual(config.base_url, "http://example.com")
Пример #7
0
 def setUp(self):
     ShopConfigFactory.create()
Пример #8
0
 def setUp(self):
     self.au = AUFactory.create()
     ShopConfigFactory.create(country=self.au)
     self.shop = Config.objects.get_current()
Пример #9
0
 def setUp(self):
     self.us = USFactory.create()
     ShopConfigFactory.create(country=self.us)
Пример #10
0
 def setUp(self):
     self.request_factory = RequestFactory()
     ShopConfigFactory.create(country=CAFactory())
Пример #11
0
 def setUp(self):
     ShopConfigFactory.create()
Пример #12
0
 def setUp(self):
     self.au = AUFactory.create()
     ShopConfigFactory.create(country=self.au)
     self.shop = Config.objects.get_current()
Пример #13
0
 def setUp(self):
     self.us = USFactory.create()
     ShopConfigFactory.create(country=self.us)
Пример #14
0
 def setUp(self):
     self.request_factory = RequestFactory()
     ShopConfigFactory.create(country=CAFactory())