Ejemplo n.º 1
0
class TestCreateRoom(unittest.TestCase):
    def setUp(self):
        self.amity = Amity()

    #test_if_can_add_more than one room
    #test_if_duplicate_entries_not_added

    def test_whether_office_already_exists(self):
        create1 = self.amity.create_room("O", "asgard")
        self.assertEqual("Room already exists",
                         create1,
                         msg="Duplicate room is being created")

    def test_if_office_created(self):
        # print (self.amity.offices[0].current_occupants)
        self.assertEqual(
            self.amity.create_room("O", "cave"),
            "We have successfully created a new office called: CAVE",
            msg="Office CANNOT be created successfully")

    def test_whether_livingspace_already_exists(self):
        create1 = self.amity.create_room("L", "statehouse")
        self.assertEqual("Room already exists",
                         create1,
                         msg="Duplicate room is being created")

    def test_if_livingspace_created(self):
        self.assertEqual(self.amity.create_room("L", "cave"),
                         "New living quarters ( CAVE ) successfully created!",
                         msg="Office CANNOT be created successfully")
Ejemplo n.º 2
0
class TestAddPerson(unittest.TestCase):
    def setUp(self):
        self.amity = Amity()

    def test_whether_fellow_already_exists(self):
        create = self.amity.add_person("WONDERWOMAN", "FELLOW", "Y")
        self.assertEqual("Person already exists",
                         create,
                         msg="Duplicate person being created")

    #test_if_person_identifier_exists
    ## what if 2 people have the same name?

    def test_if_fellow_added(self):
        room = self.amity.create_room("o", "oculus")
        ls = self.amity.create_room("l", "london")
        count = len(self.amity.fellows)
        create = self.amity.add_person("WOLVERINE", "FELLOW", "Y")
        self.assertEqual(len(self.amity.fellows),
                         count + 1,
                         msg="Fellow CANNOT be added successfully")

    def test_whether_staff_already_exists(self):
        create = self.amity.add_person("STRANGE", "STAFF", "N")
        self.assertEqual("Person already exists",
                         create,
                         msg="Duplicate person being created")

    def test_if_staff_added(self):
        room = self.amity.create_room("o", "oculus")
        count = len(self.amity.staff)
        self.amity.add_person("CYBORG", "STAFF", "N")
        import pdb
        pdb.set_trace()
        self.assertEqual(len(self.amity.staff),
                         count + 1,
                         msg="Staff CANNOT be added successfully")

    def test_if_randomly_allocated(self):
        person = self.amity.add_person("CYBORG", "STAFF", "N")
        room = self.amity.create_room("o", "Mombasa")
        self.assertTrue(person in room.current_occupants)