def test_add_character(self): test_room = Space(name="Test Room") first_test_character = Character(name="R2-D2") second_test_character = Character(name="C-3PO") fake_test_character = Character(name="R4-D4") test_room.add_character(first_test_character) test_room_characters = [i.name for i in test_room.get_characters()] self.assertIn(first_test_character.name, test_room_characters) self.assertNotIn(second_test_character.name, test_room_characters) self.assertNotIn(fake_test_character.name, test_room_characters) test_room.add_character(second_test_character) test_room_characters = [i.name for i in test_room.get_characters()] self.assertIn(first_test_character.name, test_room_characters) self.assertIn(second_test_character.name, test_room_characters) self.assertNotIn(fake_test_character.name, test_room_characters)
def test_remove_character(self): test_room = Space(name="Test Room") first_test_chrctr = Character(name="R2-D2") second_test_chrctr = Character(name="C-3PO") third_test_chrctr = Character(name="R4-D4") test_chrctrs = [first_test_chrctr, second_test_chrctr, third_test_chrctr] test_room.set_characters(test_chrctrs) test_room.remove_character(first_test_chrctr) test_room_chrctrs = [i.name for i in test_room.get_characters()] self.assertNotIn(first_test_chrctr.name, test_room_chrctrs) self.assertIn(second_test_chrctr.name, test_room_chrctrs) self.assertIn(third_test_chrctr.name, test_room_chrctrs)