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"))), )
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")
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)
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)
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"))), )
def test_base_url(self): ShopConfigFactory() config = Config.objects.get_current() self.assertEqual(config.base_url, "http://example.com")
def setUp(self): ShopConfigFactory.create()
def setUp(self): self.au = AUFactory.create() ShopConfigFactory.create(country=self.au) self.shop = Config.objects.get_current()
def setUp(self): self.us = USFactory.create() ShopConfigFactory.create(country=self.us)
def setUp(self): self.request_factory = RequestFactory() ShopConfigFactory.create(country=CAFactory())