Beispiel #1
0
    def test_create_basket_item(self):
        """
        Test creating a new basket item
        """
        with catch_signal(basket_modified) as handler:
            variant = ProductVariantFactory()
            self.post_test({'variant_id': variant.id}, 'longclaw_basket_list')

        handler.assert_called_once_with(
            basket_id=mock.ANY,  # TODO: CHECK CORRECT BASKET ID IS SENT
            sender=BasketItem,
            signal=basket_modified,
        )
Beispiel #2
0
 def setUp(self):
     self.variant = ProductVariantFactory()
     self.product_request = ProductRequest(variant=self.variant)
Beispiel #3
0
 def test_create_basket_item(self):
     """
     Test creating a new basket item
     """
     variant = ProductVariantFactory()
     self.post_test({'variant_id': variant.id}, 'longclaw_basket_list')
Beispiel #4
0
 def test_product_title(self):
     variant = ProductVariantFactory()
     self.assertEqual(variant.get_product_title(), variant.product.title)
Beispiel #5
0
 def test_variant_serializer(self):
     variant = ProductVariantFactory()
     serializer = ProductVariantSerializer(variant)
     self.assertIn('product', serializer.data)
Beispiel #6
0
 def test_out_of_stock(self):
     variant = ProductVariantFactory()
     variant.stock = 0
     variant.save()
     self.assertFalse(variant.product.in_stock)
Beispiel #7
0
 def test_stock(self):
     variant = ProductVariantFactory()
     variant.stock = 1
     variant.save()
     self.assertTrue(variant.product.in_stock)
Beispiel #8
0
 def test_price_range(self):
     variant = ProductVariantFactory()
     prices = variant.product.price_range
     self.assertTrue(prices[0] == prices[1])
Beispiel #9
0
 def test_variant_price(self):
     variant = ProductVariantFactory()
     self.assertTrue(variant.price == variant.base_price * 10)
     self.assertTrue(variant.price > 0)