Esempio n. 1
0
    def setUp(self):
        model.Person.number_of_person = 0
        self.dojo = model.Dojo("Andela_kenya")
        # allocated persons
        self.person1 = model.Staff("person1")
        self.person4 = model.Fellow("person4")
        # unallocated persons
        self.person2 = model.Staff("person2")
        self.person3 = model.Fellow("person3")

        self.room1 = model.Office("room1")
        self.room2 = model.LivingSpace("room2")

        self.room3 = model.Office("room3")
        self.room4 = model.LivingSpace("room4")

        # assing offices
        self.room1.add_occupant(self.person1)
        self.room1.add_occupant(self.person4)
        # assign livingspace
        self.room2.add_occupant(self.person4)

        self.person1.office = True
        self.person4.office = True
        self.person4.livingspace = True

        self.dojo.add_office(self.room1)
        self.dojo.add_livingspace(self.room2)
        self.dojo.add_office(self.room3)
        self.dojo.add_livingspace(self.room4)

        self.dojo.add_staff(self.person1)
        self.dojo.add_staff(self.person2)
        self.dojo.add_fellow(self.person3)
        self.dojo.add_fellow(self.person4)
    def setUp(self):
        self.room1 = model.Office("room1")
        self.room2 = model.LivingSpace("room2")
        self.room3 = model.Office("notindojo")
        self.room4 = model.LivingSpace("notindojo")
        self.room5 = model.Office("emptyroom")

        self.person1 = model.Staff("person1")
        self.person2 = model.Staff("person2")

        # update rooms with staffself.dojo,
        self.room1.add_occupant(self.person1)
        self.room1.add_occupant(self.person2)

        self.person3 = model.Fellow("person3")
        self.person4 = model.Fellow("person4")

        # update room with fellows
        self.room1.add_occupant(self.person3)
        self.room2.add_occupant(self.person4)

        self.dojo = model.Dojo("Andela_kenya")
        self.dojo.add_staff(self.person1)
        self.dojo.add_staff(self.person2)
        self.dojo.add_fellow(self.person3)
        self.dojo.add_fellow(self.person4)

        self.dojo.add_office(self.room1)
        self.dojo.add_office(self.room5)
        self.dojo.add_livingspace(self.room2)
    def setUp(self):
        self.dojo = model.Dojo("Andela-kenya")

        self.office = model.Office("Tsavo")
        self.livingspace = model.LivingSpace("hostel")

        self.staff1 = model.Staff("staff1")
        self.fellow1 = model.Fellow("fellow1")

        self.dojo.add_office(self.office)
        self.dojo.add_livingspace(self.livingspace)
    def setUp(self):
        self.dojo = model.Dojo("Andela_kenya")

        # unallocated staff
        self.staff1 = model.Staff("staff1")
        self.staff2 = model.Staff("staff2")

        # unallocated fellow
        self.fellow1 = model.Fellow("fellow1")
        self.fellow2 = model.Fellow("fellow2")

        self.office1 = model.Office("office1")
        self.livingspace1 = model.LivingSpace("livingspace1")

        # update dojo with infomation
        self.dojo.add_office(self.office1)
        self.dojo.add_livingspace(self.livingspace1)
        self.dojo.add_fellow(self.fellow1)
        self.dojo.add_fellow(self.fellow2)
        self.dojo.add_staff(self.staff1)
        self.dojo.add_staff(self.staff2)
    def setUp(self):
        model.Person.number_of_person = 0
        model.Staff.number_of_staff = 0
        model.Fellow.number_of_fellows = 0

        self.person1 = model.Person("person1")
        self.person2 = model.Person("person2")

        self.fellow1 = model.Fellow("fellow1")
        self.fellow2 = model.Fellow("fellow2", True)

        self.staff1 = model.Staff("staff1")
        self.staff2 = model.Staff("staff2")

        self.office = model.Office("testme")
        self.office1 = model.Office("HR")

        self.livingspace = model.Office('Orange')
        self.livingspace1 = model.Office('manjaro')

        self.fellow2.office = self.office1
        self.fellow2.livingspace = True
    def setUp(self):
        self.dojo1 = model.Dojo("Andela_kenya")

        self.room = model.Office("HR")
        self.room2 = model.Office("IT")

        self.room3 = model.LivingSpace("Complex_A")
        self.room4 = model.LivingSpace("Complex_B")

        self.person1 = model.Fellow("Morris")
        self.person2 = model.Fellow("new_Fellow", True)

        self.person3 = model.Staff("Ndiga")
        self.person4 = model.Staff("Someone")

        # update dojo with info
        self.dojo1.add_office(self.room)
        self.dojo1.add_office(self.room2)
        self.dojo1.add_livingspace(self.room3)
        self.dojo1.add_livingspace(self.room4)
        self.dojo1.add_staff(self.person3)
        self.dojo1.add_staff(self.person4)
Esempio n. 7
0
def add_person(names, person_type, wants_livingspace='N'):
    """
    input: firstname lastname Fellow/Staff [Y]
    """

    # validate fields data types
    if not isinstance(names, tuple) or not isinstance(person_type, str) or\
            not isinstance(wants_livingspace, str):
        raise TypeError

    # validate person_type
    person_type = person_type.lower().strip()
    if person_type not in ["fellow", "staff"]:
        raise TypeError

    # validate name
    name1 = names[0].strip().lower()
    name2 = names[1].strip().lower()
    if not name1.isalnum() or not name2.isalnum():
        return "Invalid name"
    name = name1 + " " + name2

    # validate wants_livingspace
    wants_livingspace = wants_livingspace.strip().lower()
    if wants_livingspace not in 'yn' and person_type == "fellow":
        return "Invalid choice"
    choice = True if wants_livingspace == 'y' else False

    if person_type == 'staff':
        new_person = model.Staff(name)
        new_person.office = False
    else:
        new_person = model.Fellow(name, choice)
        new_person.livingspace = False
        new_person.office = False
        new_person.wants_living = False
        if choice:
            new_person.wants_living = True
    return new_person
 def setUp(self):
     self.staff1 = model.Staff("saveSTaff1")
     self.fellow1 = model.Fellow("saveFellow1")