def __init__(self, product_code, description, market_price, rental_price, material, size): Inventory.__init__(self, product_code, description, market_price, rental_price) # Creates common instance variables from the parent class self.material = material self.size = size
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 __init__(self, product_code, description, market_price, rental_price, brand, voltage): """ Initializes class """ Inventory.__init__(self, product_code, description, market_price, rental_price) # Creates common instance variables from the parent class self.brand = brand self.voltage = voltage
def test_return_as_dictionary(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) new_dict = i.return_as_dictionary() self.assertEqual(i.product_code, new_dict["product_code"]) self.assertEqual(i.description, new_dict["description"]) self.assertEqual(i.rental_price, new_dict["rental_price"])
def test_inventory_return_to_dictionary(): """ Tests InventoryClass returning a dic of information about all the items in the dictionary """ couch = Inventory("C777", "reclining couch", 20.00, 10.00) assert couch.return_as_dictionary() == { "product_code": "C777", "description": "reclining couch", "market_price": 20.00, "rental_price": 10.00 }
def test_inventory(): """ Test for Inventory Init """ couch = Inventory("C777", "reclining couch", 20.00, 10.00) assert couch.product_code == "C777" assert couch.description == "reclining couch" assert couch.market_price == 20.00 assert couch.rental_price == 10.00
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 test_init(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.product_code, 1) self.assertEqual(i.description, "a") self.assertEqual(i.rental_price, 1.0) self.assertEqual(i.market_price, 1.0)
def test_return_item_info(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 i1 = Inventory(**item_dict) item_dict1 = {} item_dict1["item_code"] = 2 item_dict1["item_description"] = "b" item_dict1["item_rental_price"] = 2.0 item_dict1["item_price"] = 2.0 i2 = Inventory(**item_dict1) f_inventory = {} f_inventory["1"] = i1.return_as_dictionary() f_inventory["2"] = i2.return_as_dictionary() self.assertEqual( return_item_info(f_inventory, "1"), "product_code:1\ndescription:a\nmarket_price:1.0\nrental_price:1.0\n" ) self.assertEqual( return_item_info(f_inventory, "2"), "product_code:2\ndescription:b\nmarket_price:2.0\nrental_price:2.0\n" ) self.assertEqual(return_item_info(f_inventory, "z"), "Item not found in inventory")
def __init__(self, **kwargs): Inventory.__init__(self, **kwargs) # self.material = kwargs["item_material"] self.size = kwargs["size"]
def __init__(self, **kwargs): Inventory.__init__(self, **kwargs) self.brand = kwargs["brand"] self.voltage = kwargs["voltage"]