Exemplo n.º 1
0
 def test_add_new_item_furniture(self):
     text_trap = io.StringIO()
     sys.stdout = text_trap
     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"
     item_dict["item_material"] = "a"
     item_dict["size"] = "S"
     item_dict["style"] = "furniture"
     user_input = ["1", "a", "1.0", "y", "a", "S"]
     f_inventory = {}
     f = Furniture(**item_dict)
     f_inventory = {}
     with patch('builtins.input', side_effect=user_input):
         f_inventory = add_new_item(f_inventory)
     new_dict = f_inventory["1"]
     f = Furniture(**item_dict)
     new_dict1 = f.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["material"], new_dict1["material"])
     self.assertEqual(new_dict["size"], new_dict1["size"])
     sys.stdout = sys.__stdout__
Exemplo n.º 2
0
 def add_new_item_furniture(self,f_inventory):
     text_trap = io.StringIO()
     sys.stdout = text_trap
     user_input = ["1", "a", "1.0", "y", "a", "S"]
     with patch('builtins.input', side_effect=user_input):
         f_inventory = add_new_item(f_inventory)
     sys.stdout = sys.__stdout__
     return f_inventory
Exemplo n.º 3
0
 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__
Exemplo n.º 4
0
 def test_add_new_item_electrical(self):
     text_trap = io.StringIO()
     sys.stdout = text_trap
     user_input = ["2", "b", "2.0", "n", "y", "b", "2.0"]
     f_inventory = {}
     with patch('builtins.input', side_effect=user_input):
         f_inventory = add_new_item(f_inventory)
     new_dict = f_inventory["2"]
     item_dict = {}
     item_dict["item_code"] = "2"
     item_dict["item_description"] = "b"
     item_dict["item_rental_price"] = "2.0"
     item_dict["item_price"] = "2.0"
     item_dict["brand"] = "b"
     item_dict["voltage"] = "2.0"
     e = ElectricAppliances(**item_dict)
     new_dict1 = e.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["brand"], new_dict1["brand"])
     self.assertEqual(new_dict["voltage"], new_dict1["voltage"])
     sys.stdout = sys.__stdout__