def test_person_creation(self):
     """ create employees and test against their class instances """
     self.fellow = Person.create(
         'Jee Gikera', 'fellow', wants_accomodation=True)
     self.staff = Person.create('Chidi Nnadi', 'staff')
     self.assertIsInstance(self.fellow, Fellow)
     self.assertIsInstance(self.staff, Staff)
 def setup(self):
     self.office = Office()
     self.living = LivingSpace()
     self.office.populate_room_names()
     self.living.populate_room_names()
     self.f = Person.create('Jee Gikera', 'fellow', wants_accomodation=True)
     self.staff = Person.create('Chidi Nnadi', 'staff')
 def test_person_creation(self):
     """ create employees and test against their class instances """
     self.fellow = Person.create('Jee Gikera',
                                 'fellow',
                                 wants_accomodation=True)
     self.staff = Person.create('Chidi Nnadi', 'staff')
     self.assertIsInstance(self.fellow, Fellow)
     self.assertIsInstance(self.staff, Staff)
 def setup(self):
     self.office = Office()
     self.living = LivingSpace()
     self.office.populate_room_names()
     self.living.populate_room_names()
     self.f = Person.create(
         'Jee Gikera', 'fellow', wants_accomodation=True)
     self.staff = Person.create('Chidi Nnadi', 'staff')
    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_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)
Example #7
0
    def get_people_from_file(people_file):
        """ Parse from text file """
        people = []
        # read each line from the file and store in a temp list
        for line in open(people_file, 'r'):
            employee = line.rstrip('\n')
            match = re.search('^(\w+\s[^\s]+)[\s]{1,}(\w+)[\s]{0,}(\w)?',
                              employee)
            details = match.groups()
            name, role, wants_accomodation = details
            # create the person with the credentials
            person = Person.create(name, role, wants_accomodation)
            people.append(person)

        # randomly shuffle the employee list
        # to prevent unrandom FIFO behavior every time we re-allocate rooms
        random.shuffle(people)

        return people
    def get_people_from_file(people_file):
        """ Parse from text file """
        people = []
        # read each line from the file and store in a temp list
        for line in open(people_file, 'r'):
            employee = line.rstrip('\n')
            match = re.search(
                '^(\w+\s[^\s]+)[\s]{1,}(\w+)[\s]{0,}(\w)?', employee)
            details = match.groups()
            name, role, wants_accomodation = details
            # create the person with the credentials
            person = Person.create(name, role, wants_accomodation)
            people.append(person)

        # randomly shuffle the employee list
        # to prevent unrandom FIFO behavior every time we re-allocate rooms
        random.shuffle(people)

        return people