def test_price_qty_of_product(self): test2 = products() #test the price & qty for cola itemName = test2.getItemNameWithNumber(1) #get price price = test2.getItemPriceQty('price', itemName) self.assertEqual(price, 1.00) #get qty qty= test2.getItemPriceQty('qty', itemName) self.assertEqual(qty, 10) #test the price & qty for chips itemName = test2.getItemNameWithNumber(2) #get price price = test2.getItemPriceQty('price', itemName) self.assertEqual(price, .50) #get qty qty= test2.getItemPriceQty('qty', itemName) self.assertEqual(qty, 10) #test the price & qty for candy itemName = test2.getItemNameWithNumber(3) #get price price = test2.getItemPriceQty('price', itemName) self.assertEqual(price, .65) #get qty qty= test2.getItemPriceQty('qty', itemName) self.assertEqual(qty, 10)
def test_sub_qty(self): test4 = products() qty= test4.getItemPriceQty('qty', 'cola') self.assertEqual(qty, 10) test4.subQtyofItem('cola') qty= test4.getItemPriceQty('qty', 'cola') self.assertEqual(qty, 9)
def test_assoiate_number_with_product(self): test1 = products() #attempt to get cola using number 1 itemName = test1.getItemNameWithNumber(1) self.assertEqual(itemName, "cola") #attempt to get chips using number 2 itemName = test1.getItemNameWithNumber(2) self.assertEqual(itemName, "chips") #attempt to get candy using number 3 itemName = test1.getItemNameWithNumber(3) self.assertEqual(itemName, "candy") # attempt to by something not on the menu itemName = test1.getItemNameWithNumber(4) self.assertEqual(itemName, None)
from Products import products prod = products() prod.add("Питка", 100) prod.add("Домат", 100) prod.add("Зеле", 100) prod.add("Лук", 10) prod.add("Шиш", 5) prod.add("Сос", 20) prod.add("Тесто", 100) prod.add("Салам", 30) prod.add("Кашкавал", 100) prod.add("Картофи", 95) class kasa: def __init__(self): self.money = 1000 self.change = 0 self.product_use = 1 self.bill = 0 self.eho = [] self.drinks_belejka = [] def prices(self): print( "=====================================\nДюнери:\n=====================================" ) print( f"Малък: {prod.kebap['Малък']}лв. \nСреден: {prod.kebap['Среден']}лв. \nГолям: {prod.kebap['Голям']}лв." ) print(
#so that I can make buys from Products import products #used for random testing from random import randint # create the test test = machine() # create the test that can test buying test2 = machine() #did this for new test because test werent ran in order test3 = machine() #this creates required prducts via pillar kata items = products() class TestMachine(unittest.TestCase): def setUp(self): pass def test_initial_display(self): #check the display display = test.getVendDisplay() self.assertEqual(display, 'EXACT CHANGE ONLY') def test_initial_amount(self): #make sure that that no money has been inserted display = test.getTotalInserted() self.assertEqual(display, 0.00)
def test_get_all_items(self): test3 = products() allItems = test3.getAllProducts() self.assertEqual(allItems, {'cola': {'price':1.00, 'qty': 10} , 'chips': {'price': .50, 'qty': 10}, 'candy': {'price':.65, 'qty': 10} })
# this is the brains of my vending machine #so that I can accept or reject coins from Coin import coins #using coins Coins = coins() from Products import products #using products Products = products() class machine(object): def __init__(self): self.display = "INSERT COINS" self.coinsInserted=[] self.amountInserted = 0.00 self.items = {} self.returnCoin = [] self.returnCoinAmount = 0 self.acceptedCoins = {"nickle":.05, 'dime': .10, 'quarter': .25} self.coinsInMachine = [] self.amountInMachine = 0 def getVendDisplay(self): if self.display == "THANK YOU": hold = self.display if self.amountInserted > 0.00: self.display = "${0:.2f}".format(self.amountInserted) else: