def test_remove_user(self): r = Room() r.open() u1 = User() u2 = User() r.add_user(u1) r.add_user(u2) self.assertIn(u1, r.users) r.remove_user(u1) self.assertNotIn(u1, r.users) self.assertIn(u2, r.users)
def test_close_room(self): r = Room() r.open() u1 = User() u2 = User() o = User() r.add_user(u1) r.add_user(u2) r.add_owner(o) r.close() self.assertFalse(r.is_open()) self.assertEqual(len(r.users), 0) self.assertEqual(r.owner, o)
def test_add_users_to_unopened_room(self): r = Room() u = User() self.assertFalse(r.is_open()) with self.assertRaises(RoomException): r.add_user(u)
def test_room_add_user(self): r = Room() r.open() u = User() r.add_user(u) self.assertEqual(len(r.users), 1)