예제 #1
0
	def test_add_office(self):
		office = Office('MyOffice78')
		initial_room_count = len(Dojo.rooms())
		initial_office_count = len(Office.rooms())
		Office.add(office)
		new_room_count = len(Dojo.rooms())
		new_office_count = len(Office.rooms())
		self.assertEqual([initial_room_count+1, initial_office_count+1],
						 [new_room_count, new_office_count])
	def test_add_living_space(self):
		livingspace = LivingSpace('MySpace78')
		initial_room_count = len(Dojo.rooms())
		initial_livingspace_count = len(LivingSpace.rooms())
		LivingSpace.add(livingspace)
		new_room_count = len(Dojo.rooms())
		new_livingspace_count = len(LivingSpace.rooms())
		self.assertEqual([initial_room_count+1, initial_livingspace_count+1],
						 [new_room_count, new_livingspace_count])
예제 #3
0
 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")
예제 #4
0
	def test_remove_office(self):
		office = Office('MyOffice89')
		Office.add(office)
		initial_room_count = len(Dojo.rooms())
		initial_office_count = len(Office.rooms())
		Office.remove(office)
		new_room_count = len(Dojo.rooms())
		new_office_count = len(Office.rooms())
		self.assertEqual([initial_room_count-1, initial_office_count-1],
						 [new_room_count, new_office_count])
	def test_remove_living_space(self):
		livingspace = LivingSpace('MySpace89')
		LivingSpace.add(livingspace)
		initial_room_count = len(Dojo.rooms())
		initial_livingspace_count = len(LivingSpace.rooms())
		LivingSpace.remove(livingspace)
		new_room_count = len(Dojo.rooms())
		new_livingspace_count = len(LivingSpace.rooms())
		self.assertEqual([initial_room_count-1, initial_livingspace_count-1],
						 [new_room_count, new_livingspace_count])
예제 #6
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_
         }]
     })
예제 #7
0
 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)
예제 #8
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_
         }]
     })
예제 #9
0
 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)
예제 #10
0
 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)
예제 #11
0
 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)
예제 #12
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])
예제 #13
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])
예제 #14
0
 def from_name(cls, name):
     room = cls(name)
     if Dojo.has_room(room):
         room_name_type = room.name + "-" + room.type_
         if room_name_type in cls.__offices_set:
             return room
         else:
             raise ValueError("Room not found")
     else:
         raise ValueError("Room not found")
예제 #15
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])
예제 #16
0
 def clear_stores(self):
     #Clean data stores to run print tests
     Dojo.clear()
     Room.clear()
     Person.clear()
예제 #17
0
 def remove(cls, livingspace):
     cls.filter_livingspace(livingspace)
     Dojo.remove_room(livingspace)
     del cls.__livingspaces[livingspace.name]
     cls.__livingspaces_set.remove("%s-%s" %
                                   (livingspace.name, livingspace.type_))
예제 #18
0
 def test_room_count(self):
     x = Dojo.room_count()
     self.assertEqual(x, len(Dojo._Dojo__rooms))
예제 #19
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])
예제 #20
0
 def all_unallocated_rooms(cls):
     allocated = cls.all_allocated_rooms()
     all_ = Dojo.rooms()
     unallocated = all_ - allocated
     return unallocated
예제 #21
0
 def test_filter(self):
     with self.assertRaises(TypeError):
         Dojo.filter("xy")
예제 #22
0
 def remove(cls, office):
     cls.filter_office(office)
     Dojo.remove_room(office)
     del cls.__offices[office.name]
     cls.__offices_set.remove("%s-%s" % (office.name, office.type_))
예제 #23
0
 def test_rooms(self):
     self.assertTrue(isinstance(Dojo.rooms(), set))