def setUp(self): self.ranking_id = ObjectId() self.region = 'norcal' self.time = datetime.now() self.tournaments = [ObjectId(), ObjectId()] self.ranking_entry_1 = RankingEntry(rank=1, player=ObjectId(), rating=20.5) self.ranking_entry_2 = RankingEntry(rank=2, player=ObjectId(), rating=19.3) self.rankings = [self.ranking_entry_1, self.ranking_entry_2] self.ranking = Ranking(id=self.ranking_id, region=self.region, time=self.time, tournaments=self.tournaments, ranking=self.rankings) self.ranking_json_dict = { '_id': self.ranking_id, 'region': self.region, 'time': self.time, 'tournaments': self.tournaments, 'ranking': [r.dump(context='db') for r in self.rankings] }
def setUp(self): self.id_1 = ObjectId() self.ranking_entry = RankingEntry(rank=1, player=self.id_1, rating=20.5) self.ranking_entry_json_dict = { 'rank': 1, 'player': self.id_1, 'rating': 20.5 }
def setUp(self): self.mongo_client.drop_database(DATABASE_NAME) self.player_1_id = ObjectId() self.player_2_id = ObjectId() self.player_3_id = ObjectId() self.player_4_id = ObjectId() self.player_5_id = ObjectId() self.player_1 = Player(name='gaR', aliases=['gar', 'garr'], ratings={ 'norcal': Rating(), 'texas': Rating() }, regions=['norcal', 'texas'], id=self.player_1_id) self.player_2 = Player(name='sfat', aliases=['sfat', 'miom | sfat'], ratings={'norcal': Rating()}, regions=['norcal'], id=self.player_2_id) self.player_3 = Player(name='mango', aliases=['mango', 'gar'], ratings={'norcal': Rating(mu=2, sigma=3)}, regions=['socal'], id=self.player_3_id) self.player_4 = Player(name='shroomed', aliases=['shroomed'], ratings={'norcal': Rating()}, regions=['norcal'], id=self.player_4_id) self.player_5 = Player(name='pewpewu', aliases=['pewpewu'], ratings={'norcal': Rating()}, regions=['norcal', 'socal'], id=self.player_5_id) self.merge_player_1 = Player(name='CLGsFaT', aliases=['clg | sfat'], ratings={'norcal': Rating()}, regions=['norcal'], id=ObjectId()) # only includes players 1-3 self.players = [self.player_1, self.player_2, self.player_3] self.tournament_id_1 = ObjectId() self.tournament_type_1 = 'tio' self.tournament_raw_id_1 = ObjectId() self.tournament_date_1 = datetime(2013, 10, 16) self.tournament_name_1 = 'tournament 1' self.tournament_players_1 = [ self.player_1_id, self.player_2_id, self.player_3_id, self.player_4_id ] self.tournament_matches_1 = [ Match(winner=self.player_1_id, loser=self.player_2_id), Match(winner=self.player_3_id, loser=self.player_4_id) ] self.tournament_regions_1 = ['norcal'] # tournament 2 is earlier than tournament 1, but inserted after self.tournament_id_2 = ObjectId() self.tournament_type_2 = 'challonge' self.tournament_raw_id_2 = ObjectId() self.tournament_date_2 = datetime(2013, 10, 10) self.tournament_name_2 = 'tournament 2' self.tournament_players_2 = [ self.player_5_id, self.player_2_id, self.player_3_id, self.player_4_id ] self.tournament_matches_2 = [ Match(winner=self.player_5_id, loser=self.player_2_id), Match(winner=self.player_3_id, loser=self.player_4_id) ] self.tournament_regions_2 = ['norcal', 'texas'] self.tournament_1 = Tournament(id=self.tournament_id_1, name=self.tournament_name_1, type=self.tournament_type_1, date=self.tournament_date_1, regions=self.tournament_regions_1, raw_id=self.tournament_raw_id_1, players=self.tournament_players_1, matches=self.tournament_matches_1) self.tournament_2 = Tournament(id=self.tournament_id_2, name=self.tournament_name_2, type=self.tournament_type_2, date=self.tournament_date_2, regions=self.tournament_regions_2, raw_id=self.tournament_raw_id_2, players=self.tournament_players_2, matches=self.tournament_matches_2) self.tournament_ids = [self.tournament_id_1, self.tournament_id_2] self.tournaments = [self.tournament_1, self.tournament_2] self.pending_tournament_id_1 = ObjectId() self.pending_tournament_type_1 = 'tio' self.pending_tournament_raw_id_1 = ObjectId() self.pending_tournament_date_1 = datetime(2013, 10, 11) self.pending_tournament_name_1 = 'pending tournament 1' self.pending_tournament_players_1 = [ self.player_1.name, self.player_2.name, self.player_3.name, self.player_4.name ] self.pending_tournament_matches_1 = [ AliasMatch(winner=self.player_1.name, loser=self.player_2.name), AliasMatch(winner=self.player_3.name, loser=self.player_4.name) ] self.pending_tournament_regions_1 = ['norcal'] self.pending_tournament_1 = PendingTournament( id=self.pending_tournament_id_1, name=self.pending_tournament_name_1, type=self.pending_tournament_type_1, date=self.pending_tournament_date_1, regions=self.pending_tournament_regions_1, raw_id=self.pending_tournament_raw_id_1, players=self.pending_tournament_players_1, matches=self.pending_tournament_matches_1) self.pending_tournaments = [self.pending_tournament_1] self.ranking_entry_1 = RankingEntry(rank=1, player=self.player_1_id, rating=20) self.ranking_entry_2 = RankingEntry(rank=2, player=self.player_2_id, rating=19) self.ranking_entry_3 = RankingEntry(rank=3, player=self.player_3_id, rating=17.5) self.ranking_entry_4 = RankingEntry(rank=3, player=self.player_4_id, rating=16.5) self.ranking_time_1 = datetime(2013, 4, 20) self.ranking_time_2 = datetime(2013, 4, 21) self.ranking_1 = Ranking(id=ObjectId(), region='norcal', time=self.ranking_time_1, tournaments=self.tournament_ids, ranking=[ self.ranking_entry_1, self.ranking_entry_2, self.ranking_entry_3 ]) self.ranking_2 = Ranking(id=ObjectId(), region='norcal', time=self.ranking_time_2, tournaments=self.tournament_ids, ranking=[ self.ranking_entry_1, self.ranking_entry_2, self.ranking_entry_4 ]) self.ranking_3 = Ranking( id=ObjectId(), region='norcal', time=self.ranking_time_2, tournaments=self.tournament_ids, ranking=[self.ranking_entry_1, self.ranking_entry_2]) self.rankings = [self.ranking_1, self.ranking_2, self.ranking_3] self.user_id_1 = 'abc123' self.user_admin_regions_1 = ['norcal', 'texas'] self.user_1 = User(id=self.user_id_1, admin_regions=self.user_admin_regions_1, username='******', salt='nacl', hashed_password='******') self.user_id_2 = 'asdfasdf' self.user_full_name_2 = 'Full Name' self.user_admin_regions_2 = [] self.user_2 = User(id=self.user_id_2, admin_regions=self.user_admin_regions_2, username=self.user_full_name_2, salt='nacl', hashed_password='******') self.users = [self.user_1, self.user_2] self.region_1 = Region(id='norcal', display_name='Norcal') self.region_2 = Region(id='texas', display_name='Texas') self.regions = [self.region_1, self.region_2] for region in self.regions: Dao.insert_region(region, self.mongo_client, database_name=DATABASE_NAME) self.norcal_dao = Dao('norcal', self.mongo_client, database_name=DATABASE_NAME) for player in self.players: self.norcal_dao.insert_player(player) for tournament in self.tournaments: self.norcal_dao.insert_tournament(tournament) for pending_tournament in self.pending_tournaments: self.norcal_dao.insert_pending_tournament(pending_tournament) for ranking in self.rankings: self.norcal_dao.insert_ranking(ranking) for user in self.users: self.norcal_dao.insert_user(user)