コード例 #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])
コード例 #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])
コード例 #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])
コード例 #4
0
 def test_room_count(self):
     x = Dojo.room_count()
     self.assertEqual(x, len(Dojo._Dojo__rooms))