def test_reallocate_person(self): Dojo.create_room('livingspace', 'oregon') Dojo.create_room('office', 'makel') Dojo.add_person('joel', 'kanye', 'F', 'Y') self.assertIn('joel kanye', Dojo.living_space_rooms['oregon']) Dojo.create_room('GO', 'l') Dojo.reallocate_person_to_ls('Hesbon Laban', 'hela') self.assertIn('Hesbon Laban', Dojo.living_space_rooms['hela']) self.assertNotIn('Hesbon Laban', Dojo.living_space_rooms['oregon'])
def do_reallocate_person(self, arg): ''' Usage: reallocate_person <firstname> <lastname> <new_room_name>''' first_name = arg["<firstname>"] last_name = arg["<lastname>"] full_name = first_name + " " + last_name new_room = arg["<new_room_name>"] if new_room.upper() in Dojo.office_rooms: Dojo.reallocate_person_to_office(full_name.upper(), new_room.upper()) elif new_room.upper() in Dojo.ls_rooms: Dojo.reallocate_person_to_ls(full_name.upper(), new_room.upper()) else: print('%s is not a room in Dojo' % new_room)
def test_does_not_reallocate_to_a_full_ls_room(self): Dojo.create_room('livingspace', 'oregon') Dojo.create_room('office', 'makel') previous_count = len(Dojo.living_space_rooms['oregon']) Dojo.add_person('hellen', 'degenerez', 'F', 'Y') Dojo.add_person('viona', 'awuor', 'F', 'Y') Dojo.add_person('patrice', 'leah', 'F', 'Y') Dojo.add_person('okindo', 'omutuka', 'F', 'Y') current_count = len(Dojo.living_space_rooms['oregon']) self.assertEqual(previous_count + 4, current_count) Dojo.create_room('livingspace', 'oregon') Dojo.add_person('anderson', 'masese', 'F', 'Y') response = Dojo.reallocate_person_to_ls('anderson masese', 'oregon') self.assertEqual(response, 'OREGON is already full')
def test_does_reallocate_to_same_ls_room(self): Dojo.create_room('livingspace', 'oregon') Dojo.add_person('Mary', 'Mwenda', 'F', 'Y') response = Dojo.reallocate_person_to_ls('Mary Mwenda ', 'oregon') self.assertEqual(response, 'MARY MWENDA is already allocated to oregon')