def test_get_latest_price(self): """ Test to ensure get_latest_price is called with expected argument. """ self.assertEqual(100, market_prices.get_latest_price(100)) market_prices.get_latest_price = MagicMock(return_value=24) market_prices.get_latest_price(100) market_prices.get_latest_price.assert_called_with(100)
def add_new_item(): ''' Here we add a new individual item ''' # global full_inventory item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": add_new_furnature(item_code, item_description, item_rental_price, \ item_price) else: is_electric_appliance = input("Is this item an electric appliance? \ (Y/N): ") if is_electric_appliance.lower() == "y": add_new_electronics(item_code, item_description, \ item_rental_price, item_price) else: new_item = Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dict() print("New Inventory item added")
def get_price(item_code): ''' Prints "Get Price", otherwise doesn't seem to do anything... ''' # print("Get price") latest_price = get_latest_price(item_code) return latest_price
def getprice(): """ function to get price""" print("Get price") latest_price = get_latest_price(item_code) return latest_price
def add_new_item(): """Allow user to add item to inventory""" global full_inventory item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture_class.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = electric_appliances_class.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory_class.Inventory(item_code, item_description, item_price, item_rental_price) full_inventory[item_code] = new_item.return_as_dictionary() return full_inventory[item_code]
def add_new_item(): """ Prompts user to enter a new item, creates new object based on what it is """ item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input( "Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def get_price(item_code): """ Get price for an item. :param item_code: unknown :return: """ print(market_prices.get_latest_price(item_code))
def add_new_item(): ''' Here we add a new individual item ''' # global full_inventory item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = FurnitureClass(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("Is this item an electric appliance? \ (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dict() print("New Inventory item added")
def add_new_item(): """ Function to add an item (with user input) to the INVENTORY_DATA """ item_code = input("Enter item code: ") temp_data = {} temp_data['item_code'] = item_code temp_data['description'] = input("Enter item description: ") temp_data['market_price'] = market_prices.get_latest_price(item_code) temp_data['rental_price'] = input("Enter item rental price: ") is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": temp_data['material'] = input("Enter item material: ") temp_data['size'] = input("Enter item size (S,M,L,XL): ") new_item = furniture_class.Furniture(**temp_data) else: is_electric_appliance = input("Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": temp_data['brand'] = input("Enter item brand: ") temp_data['voltage'] = input("Enter item voltage: ") new_item = electric_appliances_class.ElectricAppliances(**temp_data) else: new_item = inventory_class.Inventory(**temp_data) INVENTORY_DATA[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def addnewitem(): """ Adds new item into inventory """ global FULL_INVENTORY itemcode = input("Enter item code: ") itemdescription = input("Enter item description: ") itemrentalprice = input("Enter item rental price: ") # Get price from the market prices module itemprice = market_prices.get_latest_price(itemcode) isfurniture = input("Is this item a piece of furniture? (Y/N): ") if isfurniture.lower() == "y": itemmaterial = input("Enter item material: ") itemsize = input("Enter item size (S, M, L, XL): ") newitem = furnitureclass.Furniture(itemmaterial, itemsize, itemcode, itemdescription, itemprice, itemrentalprice) else: iselectricappliance = input( "Is this item an electric appliance? (Y/N): ") if iselectricappliance.lower() == "y": itembrand = input("Enter item brand: ") itemvoltage = input("Enter item voltage: ") newitem = electricappliancesclass.ElectricAppliances( itembrand, itemvoltage, itemcode, itemdescription, itemprice, itemrentalprice) else: newitem = inventoryclass.Inventory(itemcode, itemdescription, itemprice, itemrentalprice) FULLINVENTORY[itemcode] = newitem.return_as_dictionary() print("New inventory item added")
def add_new_item(): """Add item to the inventory management system""" #global FULL_INVENTORY item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture_class.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = electric_appliances_class.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory_class.Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def add_new_item(full_inventory): """ Add a new item """ #global full_inventory item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = FC.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric = input("Is this item an electric appliance? (Y/N): ") if is_electric.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = EAC.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = IC.Inventory(item_code, item_description, item_price, item_rental_price) full_inventory[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def addNewItem(): global fullInventory itemCode = input("Enter item code: ") itemDescription = input("Enter item description: ") itemRentalPrice = input("Enter item rental price: ") # Get price from the market prices module itemPrice = market_prices.get_latest_price(itemCode) isFurniture = input("Is this item a piece of furniture? (Y/N): ") if isFurniture.lower() == "y": itemMaterial = input("Enter item material: ") itemSize = input("Enter item size (S,M,L,XL): ") newItem = furnitureClass.furniture(itemCode, itemDescription, itemPrice, itemRentalPrice, itemMaterial, itemSize) else: isElectricAppliance = input("Is this item \ an electric appliance? (Y/N): ") if isElectricAppliance.lower() == "y": itemBrand = input("Enter item brand: ") itemVoltage = input("Enter item voltage: ") newItem = electricAppliancesClass.electricAppliances( itemCode, itemDescription, itemPrice, itemRentalPrice, itemBrand, itemVoltage) else: newItem = inventoryClass.inventory(itemCode, itemDescription, itemPrice, itemRentalPrice) fullInventory[itemCode] = newItem.returnAsDictionary() print("New inventory item added")
def test_main_integration(self): """Test all functions with main as a starting point""" price = market_prices.get_latest_price(0) #Adding non categorized inventory item with main input1 = ['1', 'shoe', '1', 'n', 'n'] item1 = Inventory('1', 'shoe', price, '1') with patch('builtins.input', side_effect=input1): add_new_item() #Adding furniture item with main input2 = ['2', 'chair', '2', 'y', 'wood', 'S'] item2 = Furniture('2', 'chair', price, '2', 'wood', 'S') with patch('builtins.input', side_effect=input2): add_new_item() #Adding electric appliance with main input3 = ['3', 'stove', '3', 'n', 'y', 'LG', '100'] item3 = ElectricAppliances('3', 'stove', price, '3', 'LG', '100') with patch('builtins.input', side_effect=input3): add_new_item() actual_inventory = return_inventory() expected_inventory = { '1': item1.return_as_dictionary(), '2': item2.return_as_dictionary(), '3': item3.return_as_dictionary()} self.assertEqual(actual_inventory, expected_inventory)
def test_market_price(self): ''' As stated above. I'm injecting a value that I know will be overwritten by '24' ''' prices = market_prices.get_latest_price('123') self.assertEqual(prices, 24)
def add_new_item(): """Adds a new item to the inventory based on user-inputted item code, description, and rental price. """ # global __full_inventory__ item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("Is this item an electric " "appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = electric_appliances.ElectricAppliances( item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory.Inventory(item_code, item_description, item_price, item_rental_price) __full_inventory__[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def add_new_item(): '''doc string''' itemcode = input("Enter item code: ") itemdescription = input("Enter item description: ") itemrentalprice = input("Enter item rental price: ") # Get price from the market prices module itemprice = get_latest_price() isfurniture = input("Is this item a piece of furniture? (Y/N): ") if isfurniture.lower() == "y": itemmaterial = input("Enter item material: ") itemsize = input("Enter item size (S,M,L,XL): ") newitem = Furniture(itemcode, itemdescription, itemprice, itemrentalprice, itemmaterial, itemsize) else: iselectricappliance = input("Is this item an electric appliance?" " (Y/N): ") if iselectricappliance.lower() == "y": itembrand = input("Enter item brand: ") itemvoltage = input("Enter item voltage: ") newitem = ElectricAppliances\ (itemcode, itemdescription, itemprice, itemrentalprice, itembrand, itemvoltage) else: newitem = Inventory(itemcode, itemdescription, itemprice, itemrentalprice) FULLINVENTORY[itemcode] = newitem.returnasdictionary() print("New inventory item added") return FULLINVENTORY
def add_new_item(full_inventory): """ Add new item to inventory """ # TODO: this should clearly not be a constant or a global item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = electric_appliances.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory.Inventory(item_code, item_description, item_price, item_rental_price) full_inventory[item_code] = new_item.return_dictionary() print("New inventory item added")
def add_new_item(): '''some stuff14''' global FULL_INVENTORY item_code = input("enter item code: ") item_description = input("enter item description: ") item_rental_price = input("enter item rental price: ") # get price from the market prices module item_price = mp.get_latest_price(item_code) isfurniture = input("is this item a piece of furniture? (y/n): ") if isfurniture.lower() == "y": item_material = input("enter item material: ") itemsize = input("enter item size (s, m, l, xl): ") newitem = fc.Furniture(item_code, item_description, item_price, item_rental_price, item_material, itemsize) else: iselectricappliance = input( "is this item an electric appliance? (y/n): ") if iselectricappliance.lower() == "y": item_brand = input("enter item brand: ") itemvoltage = input("enter item voltage: ") newitem = eac.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, itemvoltage) else: newitem = ic.Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = newitem.return_as_dictionary() print("new inventory item added")
def add_new_item(): """ Add new item to inventory :return: """ # global FULL_INVENTORY item_code = input('Enter item code: ') item_description = input('Enter item description: ') item_rental_price = input('Enter item rental price: ') # Get price from the market prices module item_price = MP.get_latest_price(item_code) # item_price = market_prices.get_latest_price() is_furniture = input('Is this item a piece of furniture? (Y/N): ') if is_furniture.lower() == 'y': item_material = input('Enter item material: ') item_size = input('Enter item size (S,M,L,XL): ') new_item = FC.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input('Is this item an electric appliance? ' '(Y/N): ') if is_electric_appliance.lower() == 'y': item_brand = input('Enter item brand: ') item_voltage = input('Enter item voltage: ') new_item = \ EAC.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = IC.Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dictionary() print('New inventory item added')
def add_new_item(): """Add new item to FULL_INVENTORY, based on item type and attributes.""" item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = mkt_prc.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = \ furn_cl.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = \ el_app_cl.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = \ inven_cl.Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_data_struct() print("New inventory item added") return new_item
def test_check_market_price(self): item_dict = {} item_dict["item_code"] = 1 item_dict["item_description"] = "a" item_dict["item_rental_price"] = 1.0 item_dict["item_price"] = 1.0 i = Inventory(**item_dict) self.assertEqual(i.check_market_price(), False) i.market_price = get_latest_price() self.assertEqual(i.check_market_price(), True)
def test_add_new_item_inventory(self): text_trap = io.StringIO() sys.stdout = text_trap user_input = ["3", "c", "3.0", "n", "n"] f_inventory = {} with patch('builtins.input', side_effect=user_input): f_inventory = add_new_item(f_inventory) new_dict = f_inventory["3"] item_dict = {} item_dict["item_code"] = "3" item_dict["item_description"] = "c" item_dict["item_rental_price"] = "3.0" item_dict["item_price"] = get_latest_price() i = Inventory(**item_dict) new_dict1 = i.return_as_dictionary() self.assertEqual(new_dict["product_code"], new_dict1["product_code"]) self.assertEqual(new_dict["description"], new_dict1["description"]) self.assertEqual(new_dict["rental_price"], new_dict1["rental_price"]) self.assertEqual(new_dict["market_price"], new_dict1["market_price"]) sys.stdout = sys.__stdout__
def addnewitem(): """ function to add new item""" itemcode = input("Enter item code: ") itemdescription = input("Enter item description: ") itemrentalprice = input("Enter item rental price: ") # Get price from the market prices module itemprice = get_latest_price(itemcode) isfurniture = input("Is this item a piece of furniture? (Y/N): ") if isfurniture.lower() == "y": add_furniture(itemcode, itemdescription, itemprice, itemrentalprice) else: iselectricappliance = input("Is this item an electric appliance?" " (Y/N): ") if iselectricappliance.lower() == "y": add_appliance(itemcode, itemdescription, itemprice, itemrentalprice) add_non_furniture_nor_appliance(itemcode, itemdescription, itemprice, itemrentalprice) print("New inventory item added")
def test_integration(self): """Integration test function""" test_market_price = market_prices.get_latest_price('item_code') test_inventory_data = [1, "dining_table_description", 400, 'n', 'n'] with patch('builtins.input', side_effect=test_inventory_data): main.add_new_item() test_inventory_object = Inventory(1, "dining_table_description", test_market_price, 400) print(test_inventory_object) # test_expected_inventory_data = {'product_code': 1, 'description': 'dining_table_description', # 'market_price': 24, 'rental_price': 400} # self.assertDictEqual(test_inventory_data_values, test_expected_inventory_data) test_furniture_data = [2, "bed", "500", 'y', 'teak', 'L'] with patch('builtins.input', side_effect=test_furniture_data): main.add_new_item() test_furniture_object = Furniture(2, "bed", test_market_price, "500", 'teak', 'L') # test_electric_data = [1, 'refregirator_description', 400, 'n', 'y', 'samsung', '110v'] # with patch('builtins.input', side_effect=test_electric_data): # main.add_new_item() # print(main.FULL_INVENTORY[test_electric_data[0]]) # test_electric_data_values = main.FULL_INVENTORY[test_electric_data[0]] # # test_expected_electric_data = {'product_code': 1, 'description': 'refregirator_description', # 'market_price': 24, 'rental_price': 400, 'brand': 'samsung', 'voltage': '110v'} # self.assertDictEqual(test_expected_electric_data, test_electric_data_values) full_data_main = main.FULL_INVENTORY expected_data_main = { 1: test_inventory_object.return_as_dictionary(), 2: test_furniture_object.return_as_dictionary()} self.assertEqual(full_data_main, expected_data_main)
def get_price(item_code): """Display the price of the requested item""" print("Get price") return market_prices.get_latest_price(item_code)
def test_market_prices(self): self.market_price = get_latest_price(123) self.assertEqual(self.market_price, 24)
def test_price(self): """""Tests if correct market price gets returned""" test_price = 24 self.assertEqual(test_price, get_latest_price(403))
def get_price(): """Gets price of an item""" #item_code has been removed because the return is a constant print(market_prices.get_latest_price())
def test_market_prices(self): """Test the get_latest_price function.""" self.assertEqual(24, get_latest_price("F-12"))