def test_unallocated(self): """ test getting unallocated people if any """ amity = Amity() amity.allocate_office_space(file_path, is_a_file=True) unalloc = amity.get_unallocated() unallocated = amity.unallocated # the rooms are currently 10, each taking 4 occupants, # therefore we don't have unallocated persons self.assertIsNotNone(unalloc) self.assertIsNotNone(unallocated)
def test_unallocated(self): """ test getting unallocated people if any """ amity = Amity() amity.allocate_office_space(file_path, is_a_file=True) unalloc = amity.get_unallocated() unallocated = amity.unallocated # the rooms are currently 10, each taking 4 occupants, # therefore we don't have unallocated persons self.assertIsNotNone(unalloc) self.assertIsNotNone(unallocated)
class AllocationTestCase(unittest.TestCase): """ tests the allocation of rooms to persons """ def test_allocation_to_rooms(self): """ tests the allocation of persons to rooms """ self.fellow = Person.create( 'Jee Gikera', 'fellow', wants_accomodation='Y') self.staff = Person.create('Chidi Nnadi', 'staff') office_room = Office('valhalla') living_room = LivingSpace('blue') # store person instances for testing fellow_only.append(self.fellow) persons.append(self.staff) persons.append(self.fellow) office_results = self.staff.assign_office_space(office_room) living_results = self.fellow.assign_living_space(living_room) office_room.assign_person(self.staff) living_room.assign_person(self.fellow) self.assertTrue(self.staff.has_office()) self.assertTrue(self.fellow.has_living_space()) self.assertIsInstance(office_results, Office) self.assertIsInstance(living_results, LivingSpace) self.assertIsNotNone(living_room) self.assertIsNotNone(office_room) self.assertFalse(living_room.is_occupied()) self.assertFalse(office_room.is_occupied()) self.office = Office('GreenHouse') self.living = LivingSpace('BlueMoon') self.amity = Amity() ospace = self.amity.allocate_office_space(self.fellow) lspace = self.amity.allocate_living_space(self.fellow) allocated = self.office.get_occupants() self.assertEquals(self.staff.has_living_space(), False) self.assertEquals(self.fellow.has_living_space(), True) self.assertIsNotNone(allocated) self.assertIsNotNone(ospace) self.assertIsNotNone(lspace) def test_getting_room_occupants(self): """ tests getting a given room's occupants """ self.amity = Amity() office_results = self.amity.allocate_office_space( file_path, is_a_file=True) living_results = self.amity.allocate_living_space( file_path, is_a_file=True) office_roomies = office_results[0].get_occupants() living_roomies = living_results[0].get_occupants() self.assertIsNotNone(office_roomies) self.assertIsNotNone(living_roomies) def test_getting_all_allocations(self): """ tests getting all allocations to the building """ self.amity = Amity() self.amity.allocate_living_space(file_path, is_a_file=True) self.amity.allocate_office_space(file_path, is_a_file=True) allocations = self.amity.get_allocations() print_allocation = self.amity.print_allocations() self.assertIsNotNone(allocations) self.assertTrue(print_allocation) def test_unallocated(self): """ test getting unallocated people if any """ amity = Amity() amity.allocate_office_space(file_path, is_a_file=True) unalloc = amity.get_unallocated() unallocated = amity.unallocated # the rooms are currently 10, each taking 4 occupants, # therefore we don't have unallocated persons self.assertIsNotNone(unalloc) self.assertIsNotNone(unallocated)
class AllocationTestCase(unittest.TestCase): """ tests the allocation of rooms to persons """ def test_allocation_to_rooms(self): """ tests the allocation of persons to rooms """ self.fellow = Person.create('Jee Gikera', 'fellow', wants_accomodation='Y') self.staff = Person.create('Chidi Nnadi', 'staff') office_room = Office('valhalla') living_room = LivingSpace('blue') # store person instances for testing fellow_only.append(self.fellow) persons.append(self.staff) persons.append(self.fellow) office_results = self.staff.assign_office_space(office_room) living_results = self.fellow.assign_living_space(living_room) office_room.assign_person(self.staff) living_room.assign_person(self.fellow) self.assertTrue(self.staff.has_office()) self.assertTrue(self.fellow.has_living_space()) self.assertIsInstance(office_results, Office) self.assertIsInstance(living_results, LivingSpace) self.assertIsNotNone(living_room) self.assertIsNotNone(office_room) self.assertFalse(living_room.is_occupied()) self.assertFalse(office_room.is_occupied()) self.office = Office('GreenHouse') self.living = LivingSpace('BlueMoon') self.amity = Amity() ospace = self.amity.allocate_office_space(self.fellow) lspace = self.amity.allocate_living_space(self.fellow) allocated = self.office.get_occupants() self.assertEquals(self.staff.has_living_space(), False) self.assertEquals(self.fellow.has_living_space(), True) self.assertIsNotNone(allocated) self.assertIsNotNone(ospace) self.assertIsNotNone(lspace) def test_getting_room_occupants(self): """ tests getting a given room's occupants """ self.amity = Amity() office_results = self.amity.allocate_office_space(file_path, is_a_file=True) living_results = self.amity.allocate_living_space(file_path, is_a_file=True) office_roomies = office_results[0].get_occupants() living_roomies = living_results[0].get_occupants() self.assertIsNotNone(office_roomies) self.assertIsNotNone(living_roomies) def test_getting_all_allocations(self): """ tests getting all allocations to the building """ self.amity = Amity() self.amity.allocate_living_space(file_path, is_a_file=True) self.amity.allocate_office_space(file_path, is_a_file=True) allocations = self.amity.get_allocations() print_allocation = self.amity.print_allocations() self.assertIsNotNone(allocations) self.assertTrue(print_allocation) def test_unallocated(self): """ test getting unallocated people if any """ amity = Amity() amity.allocate_office_space(file_path, is_a_file=True) unalloc = amity.get_unallocated() unallocated = amity.unallocated # the rooms are currently 10, each taking 4 occupants, # therefore we don't have unallocated persons self.assertIsNotNone(unalloc) self.assertIsNotNone(unallocated)
import os import sys import inspect currentdir = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir) from amity import Amity # exit gracefully when the text file to read is missing if __name__ == "__main__": try: arg1 = sys.argv[1] except IndexError: print("Usage: python sample.py <text file>") sys.exit(1) amity = Amity() amity.allocate_living_space(sys.argv[1], is_a_file=True) amity.allocate_office_space(sys.argv[1], is_a_file=True) amity.get_allocations() amity.print_allocations() print amity.get_unallocated()
import os import sys import inspect currentdir = os.path.dirname(os.path.abspath( inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir) from amity import Amity # exit gracefully when the text file to read is missing if __name__ == "__main__": try: arg1 = sys.argv[1] except IndexError: print ("Usage: python sample.py <text file>") sys.exit(1) amity = Amity() amity.allocate_living_space(sys.argv[1], is_a_file=True) amity.allocate_office_space(sys.argv[1], is_a_file=True) amity.get_allocations() amity.print_allocations() print amity.get_unallocated()