Exemplo n.º 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])
Exemplo n.º 2
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])
Exemplo n.º 3
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])
Exemplo n.º 4
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")
Exemplo n.º 5
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])