def test_get_items_total_weight(self): test_item_one = Item(name="Test_Item_One", weight=2) test_item_two = Item(name="Test_Item_Two", weight=4) test_item_three = Item(name="Test_Item_Three", weight=8) test_inventory = [] test_player = Player(items=test_inventory) self.assertEqual(0, test_player.get_items_total_weight()) test_player.add_item(test_item_one) self.assertEqual(2, test_player.get_items_total_weight()) test_player.add_item(test_item_three) self.assertEqual(10, test_player.get_items_total_weight()) test_player.remove_item(test_item_one) self.assertEqual(8, test_player.get_items_total_weight())
def test_get_item_names(self): test_item_one = Item(name="Test_Item_One", weight=2) test_item_two = Item(name="Test_Item_Two", weight=4) test_inventory = [] test_player = Player(items=test_inventory) test_list = [test_item_one.name] test_player.add_item(test_item_one) self.assertEqual(test_player.get_item_names(), test_list) test_list = [test_item_one.name, test_item_two.name] test_player.add_item(test_item_two) self.assertEqual(test_player.get_item_names(), test_list) test_list = [test_item_two.name] test_player.remove_item(test_item_one) self.assertEqual(test_player.get_item_names(), test_list)
def test_add_item(self): test_item_one = Item(name="Test_Item_One", weight=2) test_item_two = Item(name="Test_Item_Two", weight=4) test_item_three = Item(name="Test_Item_Three", weight=8) test_inventory = [] test_player = Player(items=test_inventory) self.assertEqual(test_player.get_items(), test_inventory) test_player.add_item(test_item_one) self.assertIn(test_item_one, test_player.get_items()) test_player.add_item(test_item_two) self.assertIn(test_item_two, test_player.get_items()) test_player.add_item(test_item_three) self.assertIn(test_item_three, test_player.get_items())