Exemplo n.º 1
0
    def test_stock_get_sub_total_return_the_cost_of_a_line_item(self):
        item = StockItem('Fresh Diary Milk', 1000)
        self.stock.update_stock(item, 20)
        line_item = LineItem('Fresh Diary Milk', 10)

        sub_total = self.stock.get_sub_total(line_item)
        self.assertEqual(sub_total, 10000)
Exemplo n.º 2
0
 def test_stock_adds_multiple_stock_items(self):
     items = [
         StockItem('Fresh Diary Milk', 1000),
         StockItem('Bic Pen', 2000)
     ]
     for item in items:
         self.stock.update_stock(item, 20)
     self.assertEqual(
         self.stock.stock_items, {
             'Fresh Diary Milk': {
                 'name': 'Fresh Diary Milk',
                 'quantity': 20,
                 'unit_price': 1000
             },
             'Bic Pen': {
                 'name': 'Bic Pen',
                 'quantity': 20,
                 'unit_price': 2000
             }
         })
Exemplo n.º 3
0
 def test_stock_adds_new_stock_items(self):
     item = StockItem('Fresh Diary Milk', 1000)
     self.stock.update_stock(item, 20)
     self.assertEqual(
         self.stock.stock_items, {
             'Fresh Diary Milk': {
                 'name': 'Fresh Diary Milk',
                 'quantity': 20,
                 'unit_price': 1000
             }
         })
Exemplo n.º 4
0
 def test_stock_updates_existing_stock_item(self):
     item = StockItem('Fresh Diary Milk', 1000)
     self.stock.update_stock(item, 20)
     self.stock.update_stock(item, 40)
     self.assertEqual(
         self.stock.stock_items, {
             'Fresh Diary Milk': {
                 'name': 'Fresh Diary Milk',
                 'quantity': 60,
                 'unit_price': 1000
             }
         })
Exemplo n.º 5
0
    def setUp(self):
        shop = Shop('Nakumatt')
        shop.add_stock(StockItem('Blueband', 4000), 100)

        cart = ShoppingCart()
        self.customer = Customer('Mukasa John', cart)
Exemplo n.º 6
0
 def test_item_responds_to_properties(self):
     item = StockItem('Bic Pen', 2000)
     self.assertEqual([item.name, item.unit_price], ['Bic Pen', 2000])
Exemplo n.º 7
0
def stock_shop(shop):
    items = [StockItem('Blueband', 4000), StockItem('Toothpaste', 3000)]
    for item in items:
        shop.add_stock(item, 100)