Ejemplo n.º 1
0
    def test_can_add_items_of_the_same_type_into_basket(self):
        baked_beans = Item("Baked Beans", 0.99)
        basket = Basket()
        basket.add_items(baked_beans, 4)
        basket.add_items(baked_beans, 1)

        self.assertEqual(basket.items,{baked_beans: 5})
Ejemplo n.º 2
0
    def setUp(self):
        """Define the catalogue of items and basket"""

        self.baked_beans = Item("Baked Beans", 0.99)
        self.biscuits  = Item("Biscuits", 1.20)
        self.sardines  = Item("Sardines", 1.89)
        self.shampoo_small  = Item("Shampoo (Small)", 2.00)
        self.shampoo_medium = Item("Shampoo (Medium)", 2.50)
        self.shampoo_large = Item("Shampoo (Large)", 3.50)
        self.basket = Basket()
        self.catalogue = CatalogueRepository()
Ejemplo n.º 3
0
    def setUp(self):
        """Define the catalogue of items, basket and current offers"""

        self.baked_beans = Item("Baked Beans", 0.99)
        self.biscuits  = Item("Biscuits", 1.20)
        self.sardines  = Item("Sardines", 1.89)
        self.shampoo_small  = Item("Shampoo (Small)", 2.00)
        self.shampoo_medium = Item("Shampoo (Medium)", 2.50)
        self.shampoo_large = Item("Shampoo (Large)", 3.50)
        self.basket = Basket()
        self.many_of_type_offer = {"Baked Beans" : 3}
        self.percentage_offer = {"Sardines" : 0.25}
        self.cheapest_item_offer = [["Shampoo (Small)", "Shampoo (Medium)", "Shampoo (Large)"]]
        self.users_offer = Offer(self.basket.items)
        self.cost = BasketCostCalculator(self.basket)
Ejemplo n.º 4
0
    def test_can_create_item_with_positive_price(self):
        price = 0.01
        baked_beans = Item("Baked Beans", price)

        self.assertIsInstance(baked_beans, Item)
Ejemplo n.º 5
0
    def test_cannot_add_unavailable_items_into_basket(self):
        baked_beans = Item("Baked Beans", 0.99)
        baked_beans.set_out_of_stock()
        basket = Basket()

        self.assertRaises(ItemOutOfStockException, basket.add_items, baked_beans, 1)
Ejemplo n.º 6
0
    def test_can_insert_items_into_empty_basket(self):
        baked_beans = Item("Baked Beans", 0.99)
        basket = Basket()
        basket.add_items(baked_beans, 4)

        self.assertEqual(basket.items,{baked_beans: 4})
Ejemplo n.º 7
0
    def test_cannot_create_item_with_zero_price(self):
        price = 0

        with self.assertRaises(NegativePriceDetectedException) as error:
            Item("Baked Beans", price)
        self.assertEqual('the price of the item should be a positive number', str(error.exception))