示例#1
0
    def test_last_restocked_is_none(self):
        expected_date = datetime.date.today() + datetime.timedelta(days=7)
        brand = BrandFactory(restock_interval=7)
        product = ProductFactory()
        product.brands.add(brand)

        self.assertEqual(product.stock_due_date(), expected_date)
示例#2
0
    def test_its_within_a_normal_range(self):
        last_week = datetime.date.today() - datetime.timedelta(days=7)
        expected_date = datetime.date.today() + datetime.timedelta(days=7)
        brand = BrandFactory(restock_interval=14, last_restocked=last_week)
        product = ProductFactory(brands=[brand])

        self.assertEqual(product.stock_due_date(), expected_date)
示例#3
0
    def test_its_within_a_normal_range(self):
        last_week = datetime.date.today() - datetime.timedelta(days=7)
        expected_date = datetime.date.today() + datetime.timedelta(days=7)
        brand = BrandFactory(restock_interval=14, last_restocked=last_week)
        product = ProductFactory(brands=[brand])

        self.assertEqual(product.stock_due_date(), expected_date)
示例#4
0
    def test_we_know_when_its_coming(self):
        due_on = datetime.date.today() + datetime.timedelta(days=7)
        brand = BrandFactory(stock_due_on=due_on)
        product = ProductFactory()
        product.brands.add(brand)

        self.assertEqual(product.stock_due_date(), due_on)
示例#5
0
    def test_we_have_no_idea(self):
        expected_date = datetime.date.today() + datetime.timedelta(days=14)
        last_month = datetime.date.today() - datetime.timedelta(days=31)
        brand = BrandFactory(
            restock_interval=14, stock_due_on=last_month, last_restocked=last_month
        )
        product = ProductFactory(brands=[brand])

        self.assertEqual(product.stock_due_date(), expected_date)
示例#6
0
    def test_we_have_no_idea(self):
        expected_date = datetime.date.today() + datetime.timedelta(days=14)
        last_month = datetime.date.today() - datetime.timedelta(days=31)
        brand = BrandFactory(
            restock_interval=14, stock_due_on=last_month, last_restocked=last_month
        )
        product = ProductFactory(brands=[brand])

        self.assertEqual(product.stock_due_date(), expected_date)
示例#7
0
    def test_cart_adding(self, retest=False):
        """
        Validate we can add some items to the cart
        """
        product = ProductFactory()

        if not retest:
            response = self.client.get(product.get_absolute_url())
            self.assertContains(response, str(product), count=2, status_code=200)

        data = {"productname": product.slug, "1": "L", "2": "BL", "quantity": 2}
        response = self.client.post(prefix + "/cart/add/", data)
        if not retest:
            self.assertRedirects(
                response, prefix + "/cart/", status_code=302, target_status_code=200
            )
        response = self.client.get(prefix + "/cart/")
        expect = (
            '<a href="%s/product/dj-rocks-l-bl/">Django Rocks shirt (Large/Blue)</a>'
            % (prefix)
        )
        self.assertContains(response, expect, count=1, status_code=200)
示例#8
0
    def testCartAddVerifyVeto(self):
        """Test that vetoes from `signals.satchmo_cart_add_verify` are caught and cause an error."""
        try:
            cart = Cart()
            cart.save()
            p = ProductFactory()
            cart.add_item(p, 1)
            TestOrderFactory()
            self.fail("Should have thrown a CartAddProhibited error")
        except CartAddProhibited:
            pass

        self.assertEqual(len(cart), 0)
示例#9
0
    def test_cart_adding(self, retest=False):
        """
        Validate we can add some items to the cart
        """
        product = ProductFactory()

        if not retest:
            response = self.client.get(product.get_absolute_url())
            self.assertContains(response, str(product), count=2, status_code=200)

        data = {"productname": product.slug, "1": "L", "2": "BL", "quantity": 2}
        response = self.client.post(prefix + "/cart/add/", data)
        if not retest:
            self.assertRedirects(
                response, prefix + "/cart/", status_code=302, target_status_code=200
            )
        response = self.client.get(prefix + "/cart/")
        expect = (
            '<a href="%s/product/dj-rocks-l-bl/">Django Rocks shirt (Large/Blue)</a>'
            % (prefix)
        )
        self.assertContains(response, expect, count=1, status_code=200)
示例#10
0
    def test_restock_interval_is_none(self):
        brand = BrandFactory()
        product = ProductFactory(brands=[brand])

        self.assertIsNone(product.stock_due_date())
示例#11
0
    def test_stock_due_on_is_none(self):
        expected_date = datetime.date.today() + datetime.timedelta(days=14)
        brand = BrandFactory(restock_interval=14)
        product = ProductFactory(brands=[brand])

        self.assertEqual(product.stock_due_date(), expected_date)
示例#12
0
 def test_has_stock(self):
     product = ProductFactory(items_in_stock=1)
     self.assertIsNone(product.stock_due_date())
示例#13
0
    def test_last_restocked_is_none(self):
        expected_date = datetime.date.today() + datetime.timedelta(days=7)
        brand = BrandFactory(restock_interval=7)
        product = ProductFactory(brands=[brand])

        self.assertEqual(product.stock_due_date(), expected_date)
示例#14
0
    def test_restock_interval_is_none(self):
        brand = BrandFactory()
        product = ProductFactory(brands=[brand])

        self.assertIsNone(product.stock_due_date())
示例#15
0
    def test_we_know_when_its_coming(self):
        due_on = datetime.date.today() + datetime.timedelta(days=7)
        brand = BrandFactory(stock_due_on=due_on)
        product = ProductFactory(brands=[brand])

        self.assertEqual(product.stock_due_date(), due_on)
示例#16
0
 def test_has_stock(self):
     product = ProductFactory(items_in_stock=1)
     self.assertIsNone(product.stock_due_date())