def test_return_dict(self): """calls the return_as_dictionary function on the inventory class""" item = Inventory("1234", "Book", "$100", "$75") item_info = item.return_as_dictionary() self.assertEqual(item_info, {'product_code': '1234', 'description': 'Book', 'market_price': '$100', 'rental_price': '$75'})
def __init__(self, product_code, description, market_price, rental_price, brand, voltage): Inventory.__init__(self, product_code, description, market_price, rental_price) self.brand = brand self.voltage = voltage
def __init__(self, productcode, description, marketprice, rentalprice, brand, voltage): Inventory.__init__(self, productcode, description, marketprice, rentalprice) # Creates common instance variables from the parent class self.brand = brand self.voltage = voltage
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 item1 = ['1', 'shoe', '1', 'n', 'n'] with patch('builtins.input', side_effect=item1): main.add_new_item() unintegrated_item1 = Inventory(['1', 'shoe', price, '1']) #Adding furniture item with main item2 = ['2', 'chair', '2', 'y', 'wood', 'S'] with patch('builtins.input', side_effect=item2): main.add_new_item() unintegrated_item2 = Furniture(['2', 'chair', price, '2'], 'wood', 'S') #Adding electric appliance with main item3 = ['3', 'stove', '3', 'n', 'y', 'LG', '100'] with patch('builtins.input', side_effect=item3): main.add_new_item() unintegrated_item3 = ElectricAppliances(['3', 'stove', price, '3'], 'LG', '100') actual_inventory = main.return_full_inventory() expected_inventory = { '1': unintegrated_item1.return_as_dictionary(), '2': unintegrated_item2.return_as_dictionary(), '3': unintegrated_item3.return_as_dictionary() } self.assertEqual(actual_inventory, expected_inventory)
def test_add_new_inventory(self): Inventory = MagicMock(return_value=0) new_item = Inventory(**item_info) Inventory.assert_called_with(product_code='12345', description='refrigerator', market_price='2100.00', rental_price='140.00')
def setUp(self): self.product_dict = {} self.product_dict['product_code'] = 100 self.product_dict['description'] = 'Chair' self.product_dict['market_price'] = 200 self.product_dict['rental_price'] = 50 self.inventory = Inventory(**self.product_dict)
def setUp(self): self.FULL_INVENTORY = {} self.SIMPLE_INVENTORY = {} # setup refrigerator in inventory self.refrigerator = ElectricAppliances(product_code=1, description='refrigerator', market_price=24, rental_price=15, brand='kenmore', voltage=120) refrigerator_output = self.refrigerator.return_as_dictionary() item_code = refrigerator_output['product_code'] self.FULL_INVENTORY[item_code] = self.refrigerator.return_as_dictionary() # setup sofa in inventory self.sofa = Furniture(product_code=2, description='sofa', market_price=24, rental_price=12, material='leather', size='L') sofa_output = self.sofa.return_as_dictionary() item_code = sofa_output['product_code'] self.FULL_INVENTORY[item_code] = self.sofa.return_as_dictionary() # setup a simple inventory to test class self.simple_inventory = Inventory(product_code=1, description='refrigerator', market_price=24, rental_price=15) invetory_output = self.simple_inventory.return_as_dictionary() item_code = invetory_output['product_code'] self.SIMPLE_INVENTORY[item_code] = invetory_output # user inputs self.update_inventory = [ [1, 'refrigerator', 15, 'n', 'y', 'kenmore', 120], [2, 'sofa', 12, 'y', 'leather', 'L'], [3, 'hops', 20, 'n', 'n'] ]
def test_inventory_dict(self): """Test to confirm proper info translation to a dict.""" trial_instance = Inventory('1111', 'product description', 200.00, 50.00) trial_instance_dict = trial_instance.return_as_dictionary() self.assertEqual(trial_instance_dict, {'product_code': '1111', 'description': 'product description', 'market_price': 200.00, 'rental_price': 50.00})
def __init__(self, product_code, description, market_price, rental_price, material, size): # Creates common instance variables from the parent class Inventory.__init__(self, product_code, description, market_price, rental_price) self.material = material self.size = size
def __init__(self, product_code, description, market_price, rental_price, material, size): """ init """ Inventory.__init__(self, product_code, description, market_price, rental_price) self.material = material self.size = size
def test_integration(self): '''testing integration''' # integrate market price market_price = market_prices.get_latest_price(1) #create a dict mocking items item_one = ['1', 'Painting', '50', 'n', 'n'] item_two = ['2', 'Desk', '100', 'y', 'wood', 'L'] item_three = ['3', 'Washer', '200', 'n', 'y', 'Kenmore', '120'] with patch('builtins.input', side_effect=item_one): main.add_new_item() with patch('builtins.input', side_effect=item_two): main.add_new_item() with patch('builtins.input', side_effect=item_three): main.add_new_item() test_dict = { '1': { 'product_code': '1', 'description': 'Painting', 'market_price': 24, 'rental_price': '50' }, '2': { 'product_code': '2', 'description': 'Desk', 'market_price': 24, 'rental_price': '100', 'material': 'wood', 'size': 'L' }, '3': { 'product_code': '3', 'description': 'Washer', 'market_price': 24, 'rental_price': '200', 'brand': 'Kenmore', 'voltage': '120' } } # create items using the class modules class_item_one = Inventory('1', 'Painting', market_price, '50') class_item_two = Furniture('2', 'Desk', market_price, '100', 'wood', 'L') class_item_three = ElectricAppliances('3', 'Washer', market_price, '200', 'Kenmore', '120') class_dict = { '1': class_item_one.return_as_dictionary(), '2': class_item_two.return_as_dictionary(), '3': class_item_three.return_as_dictionary() } # compare the items built with the class modules with the mock test items self.assertEqual(class_dict, test_dict)
def __init__(self, product_code, description, market_price, rental_price, brand, voltage): """Initializes electric appliances 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 setUp(self): """setUP Method to create instances of each class""" self.inventory_1 = Inventory('1234', 'lamp', '45', '10') self.inventory_1_dic = self.inventory_1.return_as_dictionary() self.electric_appliances_1 =ElectricAppliances('4455', 'TV', '2200', '140','Samsung', '120') self.electric_appliances_1_dic = self.electric_appliances_1.return_as_dictionary() self.furniture_1 = Furniture('2020', 'sofa', '1200', '100', 'leather', '22x33x44') self.furniture_1_dic = self.furniture_1.return_as_dictionary()
def test_return_as_dict(self): base_dict = Inventory('a', 'b', 100, 150) dict_output = dict() dict_output['productCode'] = 'a' dict_output['description'] = 'b' dict_output ['marketPrice'] = 100 dict_output ['rentalPrice'] = 150 self.assertDictEqual(base_dict.return_as_dictionary(), dict_output)
def setUp(self): self.product_code = 199021 self.description = 'na' self.market_price = 100 self.rental_price = 500 self.check_inventory = Inventory(self.product_code, self.description, self.market_price, self.rental_price)
def test_return_dict(self): inv = Inventory(125, 'Test Item', 50, 80) inv_dict = inv.return_as_dictionary() test_dict = {'product_code': 125, 'description': 'Test Item', 'market_price': 50, 'rental_price': 80} self.assertEqual(inv_dict, test_dict)
def test_inventory(self): """tests the adding inventory item functionality""" nintendo64 = Inventory('N64', 'Nintendo 64', 200, 75) compare = {'productCode':'N64', 'description':'Nintendo 64', 'marketPrice':200, 'rentalPrice':75} self.assertDictEqual(nintendo64.return_as_dictionary(), compare)
def test_inventory(self): inv = {'product_code': '545', 'description': 'pan', 'market_price': 42.0, 'rental_price': 13.0} details = ('545', 'pan', 42.0, 13.0) inv_test = Inventory(*details) self.assertEqual(inv, inv_test.return_as_dictionary())
def test_inventory(self): """best the base inventory class""" test = Inventory(0, 'desc', 1, 2) self.assertEqual(test.return_as_dictionary(), {'product_code': 0, 'description': 'desc', 'market_price': 1, 'rental_price': 2})
def test_inventory(self): inv = Inventory('Y43', 'Screwdriver', 5, 1) inv_dict = inv.return_as_dictionary() assert inv_dict == { 'product_code': 'Y43', 'description': 'Screwdriver', 'market_price': 5, 'rental_price': 1 }
def __init__(self, product_code, description, market_price, rental_price, brand, voltage): # pylint: disable=too-many-arguments # Creates common instance variables from the parent class Inventory.__init__(self, product_code, description, market_price, rental_price) self.brand = brand self.voltage = voltage
def test_inventory(self): inv_dict_test = { 'product_code': '555', 'description': 'black', 'market_price': 250, 'rental_price': 30 } inv_dict = Inventory('555', 'black', 250, 30) self.assertEqual(inv_dict_test, inv_dict.return_as_dictionary())
def __init__(self, product_code, description, market_price, rental_price, brand, voltage): # Creates common instance variables from the parent class self.brand = brand self.voltage = voltage Inventory.__init__(self, product_code, description, market_price, rental_price) self.output_dict['brand'] = self.brand self.output_dict['voltage'] = self.voltage
def test_inventory(self): gold = { 'productCode': 'K2', 'description': 'Snowboard', 'marketPrice': 1000, 'rentalPrice': 10 } snow_board = Inventory('K2', 'Snowboard', 1000, 10) self.assertDictEqual(gold, snow_board.return_as_dictionary())
def test_inventory(self): i = { 'product_code': '300', 'description': 'recliner', 'market_price': 60.0, 'rental_price': 20.0 } d = ('300', 'recliner', 60.0, 20.0) test = Inventory(*d) self.assertEqual(i, test.return_as_dictionary())
def test_inventory(self): test_inv = Inventory(1234, "test product", 567, 246) self.assertIsInstance(test_inv, Inventory) test_dict = { "product_code": 1234, "description": "test product", "market_price": 567, "rental_price": 246 } self.assertDictEqual(test_dict, test_inv.return_as_dictionary())
def test_inventory(self): test_inventory = Inventory(self.product_code, self.description, self.market_price, self.rental_price) self.assertDictEqual( { "product_code": self.product_code, "description": self.description, "market_price": self.market_price, "rental_price": self.rental_price }, test_inventory.return_as_dictionary())
def test_return_as_dict(self): inventory = Inventory(1, "item", 5, 5) test_dict = { 'product_code': 1, 'description': "item", 'market_price': 5, 'rental_price': 5 } self.assertEqual(test_dict, inventory.return_as_dictionary())
def __init__(self, inventory_item, material, size): Inventory.__init__(self, inventory_item.product_code, inventory_item.description, inventory_item.market_price, inventory_item.rental_price) # Creates common instance variables from the parent class self.material = material self.size = size
def test_inventory(self): """Tests the creation of an instance for inventory object""" test_dict = { 'product_code': 1011, 'description': 'SuperToy', 'market_price': 50, 'rental_price': 10 } test_inv = Inventory(1011, 'SuperToy', 50, 10) self.assertEqual(test_dict, test_inv.return_as_dictionary())