def add_new_item(): """ add 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 = 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.Electric(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") return FULL_INVENTORY
def test_inventory_return_as_dict(self): item = inventory.Inventory(**self.data) result = item.return_as_dictionary() self.assertEqual(len(self.data), len(result)) for name, value in self.data.items(): self.assertEqual(value, result[name])
def test_inventory_create(self): item = inventory.Inventory( self.data["product_code"], self.data["description"], self.data["market_price"], self.data["rental_price"]) self.assertEqual(self.data["product_code"], item.product_code) self.assertEqual(self.data["description"], item.description) self.assertEqual(self.data["market_price"], item.market_price) self.assertEqual(self.data["rental_price"], item.rental_price)
def add_inventory(properties, pricing): ''' Add new inventory item :param properties: inventory properties ''' inventory_item = inventory.Inventory( properties["product_code"], properties["description"], pricing.get_latest_price(properties["product_code"]), properties["rental_price"]) FULL_INVENTORY[properties["product_code"]] = inventory_item
def add_new_item(): """ Adds new item to the 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): ") print(f"is_furniture={is_furniture}") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") print(item_size) new_item = furniture.Furniture( product_code=item_code, description=item_description, market_price=item_price, rental_price=item_rental_price, material=item_material, size=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( product_code=item_code, description=item_description, market_price=item_price, rental_price=item_rental_price, brand=item_brand, voltage=item_voltage, ) else: new_item = inventory.Inventory( product_code=item_code, description=item_description, market_price=item_price, rental_price=item_rental_price, ) FULL_INVENTORY[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def test_inventory_sort_key(self): item = inventory.Inventory(**self.data) result = inventory.Inventory.sort_key(item) self.assertEqual(result, (item.description, item.product_code))