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, )
def setUp(self): self.variant = ProductVariantFactory() self.product_request = ProductRequest(variant=self.variant)
def test_create_basket_item(self): """ Test creating a new basket item """ variant = ProductVariantFactory() self.post_test({'variant_id': variant.id}, 'longclaw_basket_list')
def test_product_title(self): variant = ProductVariantFactory() self.assertEqual(variant.get_product_title(), variant.product.title)
def test_variant_serializer(self): variant = ProductVariantFactory() serializer = ProductVariantSerializer(variant) self.assertIn('product', serializer.data)
def test_out_of_stock(self): variant = ProductVariantFactory() variant.stock = 0 variant.save() self.assertFalse(variant.product.in_stock)
def test_stock(self): variant = ProductVariantFactory() variant.stock = 1 variant.save() self.assertTrue(variant.product.in_stock)
def test_price_range(self): variant = ProductVariantFactory() prices = variant.product.price_range self.assertTrue(prices[0] == prices[1])
def test_variant_price(self): variant = ProductVariantFactory() self.assertTrue(variant.price == variant.base_price * 10) self.assertTrue(variant.price > 0)