Exemple #1
0
 def test_add_new_room(self):
     room = LivingSpace("hl")
     initial_room_count = Dojo.room_count()
     initial_found_state = Dojo.has_room(room)
     Dojo.add_room(room)
     new_room_count = Dojo.room_count()
     new_found_state = Dojo.has_room(room)
     self.assertEqual([new_room_count, new_found_state],
                      [initial_room_count + 1, not initial_found_state])
 def test_print_populated_room(self):
     self.clear_stores()
     office = Office("NDO")
     Dojo.add_room(office)
     fellow = Fellow("Xone", "Ndobile", "0856443334", "y")
     fellow.register()
     office.allocate_to(fellow)
     allocations = office.allocations()
     output = Room.members(allocations)
     self.assertEqual(output, " 0856443334, NDOBILE, XONE, FELLOW\n")
Exemple #3
0
 def test_remove_existing_room(self):
     room = LivingSpace("xd")
     Dojo.add_room(room)
     initial_room_count = Dojo.room_count()
     initial_found_state = Dojo.has_room(room)
     Dojo.remove_room(room)
     new_room_count = Dojo.room_count()
     new_found_state = Dojo.has_room(room)
     self.assertEqual([new_room_count, new_found_state],
                      [initial_room_count - 1, not initial_found_state])
Exemple #4
0
 def add(cls, office):
     cls.filter_office(office)
     Dojo.add_room(office)
     cls.__offices_set.add("%s-%s" % (office.name, office.type_))
     cls.__offices.update({
         office.name: [{
             "capacity": office.capacity
         }, {
             "type_": office.type_
         }]
     })
 def test_print_existing_allocations_to_screen(self):
     self.clear_stores()
     office = Office("NDO2")
     Dojo.add_room(office)
     fellow = Fellow("Xone2", "Ndobile2", "0856443324", "y")
     fellow.register()
     office.allocate_to(fellow)
     allocations_ = Room.all_allocations()
     output = Room.members(allocations_, room_tag=True)
     expected_output = " NDO2-OFFICE, 0856443324, NDOBILE2, XONE2, FELLOW\n"
     self.assertEqual(output, expected_output)
Exemple #6
0
 def test_add_existing_room(self):
     room = Office("yc")
     Dojo.add_room(room)
     initial_room_count = Dojo.room_count()
     initial_found_state = Dojo.has_room(room)
     with self.assertRaises(ValueError):
         Dojo.add_room(room)
     new_room_count = Dojo.room_count()
     new_found_state = Dojo.has_room(room)
     self.assertEqual([new_room_count, new_found_state],
                      [initial_room_count, initial_found_state])
Exemple #7
0
 def add(cls, livingspace):
     cls.filter_livingspace(livingspace)
     Dojo.add_room(livingspace)
     cls.__livingspaces_set.add("%s-%s" %
                                (livingspace.name, livingspace.type_))
     cls.__livingspaces.update({
         livingspace.name: [{
             "capacity": livingspace.capacity
         }, {
             "type_": livingspace.type_
         }]
     })
 def test_print_existing_unallocated_to_screen(self):
     self.clear_stores()
     office = Office("NDO4")
     Dojo.add_room(office)
     fellow = Fellow("Xone4", "Ndobile4", "0856443354", "y")
     fellow.register()
     office.allocate_to(fellow)
     fellow = Fellow("Xone5", "Ndobile6", "0856443009", "n")
     fellow.register()
     office.allocate_to(fellow)
     fellow = Fellow("Xone3", "Ndobile3", "0856443344", "y")
     fellow.register()
     output = Room.all_unallocated_persons()
     expected_output = "0856443344, NDOBILE3, XONE3, FELLOW\n"
     self.assertEqual(output, expected_output)
 def test_print_existing_allocations_to_default_file(self):
     self.clear_stores()
     office = Office("ND2")
     Dojo.add_room(office)
     fellow = Fellow("Xne2", "Ndoile2", "0868443324", "y")
     fellow.register()
     office.allocate_to(fellow)
     allocations_ = Room.all_allocations()
     expected_output = Room.members(allocations_, room_tag=True)
     Room.to_file(expected_output)
     path = "output/"
     f = open(path + "File.txt", "r")
     output = f.read()  #"NDO2-Office, 0856443324, NDOBILE2, XONE2, FELLOW"
     f.close()
     self.assertEqual(expected_output, output)
 def test_print_existing_allocations_to_specific_file(self):
     self.clear_stores()
     office = Office("ND88")
     Dojo.add_room(office)
     fellow = Fellow("Xne88", "Ndoile88", "086800000", "y")
     fellow.register()
     office.allocate_to(fellow)
     allocations_ = Room.all_allocations()
     expected_output = Room.members(allocations_, room_tag=True)
     file_name = office.name + "-Allocations"
     Room.to_file(expected_output, file_name)
     path = "output/"
     f = open(path + file_name + ".txt", "r")
     output = f.read()
     f.close()
     self.assertEqual(expected_output, output)
Exemple #11
0
 def test_has_room(self):
     room = Office("x")
     x = Dojo.has_room(room)
     Dojo.add_room(room)
     y = Dojo.has_room(room)
     self.assertEqual([x, y], [False, True])