def test_length(self): test_room = Room(None, None) for test_user in USERS: test_room.add_user(test_user) self.assertEqual(len(test_room), len(USERS))
def create_tables(cur): User.create_table(cur) Room.create_table(cur) Message.create_table(cur) RoomInvitedUsers.create_table(cur) RoomVideoPlaylist.create_table(cur) Video.create_table(cur)
def test_remove_users_success(self): test_room = Room(None, None) for test_user in USERS: test_room.add_user(test_user) test_room.remove_user(USERS[0]) self.assertFalse(test_room.has_user(USERS[0]))
def test_reaches_vote_threshold(self): test_room = Room(None, None) for entry in REACHES_VOTE_THRESHOLDS: if USER_COUNT in entry: for i in range(entry[USER_COUNT]): test_room.add_user(User(None, sid=i)) test_room.vote_threshold = entry[THRESHOLD] self.assertEqual(test_room.reaches_vote_threshold(entry[INPUT]), entry[OUTPUT]) if len(test_room) != 0: test_room.empty_room()
def create_room(self, room_id): if room_id in self.rooms: room = self.rooms[room_id] else: room = Room(self.socketio, room_id) self.rooms[room.room_id] = room if self.db_connected(): cur = self.db.cursor() room.insert_to_db(cur) self.db.commit() cur.close() return room
def test_is_creator_fail(self): test_room = Room(None, None) test_room.add_user(USERS[0]) test_room.set_creator(None) self.assertFalse(test_room.is_creator(USERS[0]))
def test_is_creator_success(self): test_room = Room(None, None) test_room.add_user(USERS[0]) test_room.set_creator(USERS[0]) self.assertTrue(test_room.is_creator(USERS[0])) test_room.set_creator(USERS[1]) self.assertTrue(test_room.has_user(USERS[1])) self.assertTrue(test_room.is_creator(USERS[1]))
def test_empty_room(self): test_room = Room(None, None) test_room.add_user(USERS[0]) test_room.empty_room() self.assertTrue(len(test_room) == 0)
def test_remove_users_fail(self): test_room = Room(None, None) test_room.add_user(USERS[0]) test_room.remove_user(USERS[1]) self.assertFalse(test_room.has_user(USERS[1]))
def test_add_users(self): test_room = Room(None, None) for test_user in USERS: test_room.add_user(test_user) self.assertTrue(test_room.has_user(test_user))
def test_generate_room_code(self): random.seed(7883) self.assertEqual(Room(None, None).room_code, 'Zp5s_mMGCaTykVbk')