Example #1
0
    def create_ranking(self, **kwargs):
        kwargs = merge_args(
            dict(created=utcnow(),
                 data_time=utcnow(),
                 min_data_time=utcnow(),
                 max_data_time=utcnow(),
                 status=Ranking.COMPLETE_WITH_DATA,
                 season=self.season), **kwargs)

        self.ranking = Ranking.objects.create(**kwargs)
        return self.ranking
Example #2
0
 def create_player(self, **kwargs):
     kwargs = merge_args(
         {
             'bid': randint(0, 1e9),
             'region': Region.EU,
             'realm': 1,
             'mode': Mode.TEAM_1V1,
             'season': self.season,
             'race': Race.ZERG,
             'name': uniqueid(12),
             'clan': uniqueid(32),
             'tag': uniqueid(6)
         }, **kwargs)
     self.player = Player(**kwargs)
     self.player.save()
     return self.player
Example #3
0
def gen_member(**kwargs):
    """ Generate member as returned from ApiLadder and used by process_ladder. """
    return merge_args(
        {
            "bid": randint(1, 1e6),
            "realm": 0,
            "name": uniqueid(length=12),
            "clan": uniqueid(length=32),
            "tag": uniqueid(length=6),
            "join_time": int(to_unix(utcnow())),
            "points": float(randint(0, 2000)),
            "wins": randint(0, 200),
            "mmr": randint(1000, 5000),
            "losses": randint(0, 200),
            "race": choice([Race.ZERG, Race.PROTOSS, Race.TERRAN, Race.RANDOM])
        }, **kwargs)
Example #4
0
    def create_ranking_data(self, raw=True, **kwargs):
        kwargs = merge_args(dict(ranking=self.ranking, updated=utcnow()),
                            kwargs)
        data = kwargs.pop('data', [])
        ranking = kwargs['ranking']

        for team_rank in data:
            self._default_team_rank(team_rank)
            ranking.sources.add(self.get(Cache, pk=team_rank['source_id']))

        self.ranking_data = RankingData.objects.create(**kwargs)
        sc2.save_ranking_data_raw(self.db_name, ranking.id, 0, data, True)
        if not raw:
            cpp = sc2.RankingData(self.db_name, Enums.INFO)
            cpp.load(ranking.id)
            cpp.save_data(ranking.id, ranking.season_id, to_unix(utcnow()))
            cpp.release()

        return self.ranking_data
Example #5
0
    def create_team(self, **kwargs):
        kwargs = merge_args(
            dict(region=Region.EU,
                 mode=Mode.TEAM_1V1,
                 season=self.season,
                 version=Version.HOTS,
                 league=League.GOLD,
                 member0=self.player,
                 member1=None,
                 member2=None,
                 member3=None,
                 race0=Race.ZERG,
                 race1=Race.UNKNOWN,
                 race2=Race.UNKNOWN,
                 race3=Race.UNKNOWN), **kwargs)

        self.team = Team(**kwargs)
        self.team.save()
        return self.team
Example #6
0
 def create_season(self, **kwargs):
     kwargs = merge_args(
         {
             'id': 16,
             'start_date': '2013-11-11',
             'end_date': '2014-01-03',
             'name': '2013 Season 6',
             'year': 2013,
             'number': 6,
             'version': Version.HOTS
         }, **kwargs)
     try:
         self.get(Season, id=kwargs['id'])
         raise AssertionError("Season with id %d already exists." %
                              kwargs['id'])
     except Season.DoesNotExist:
         pass
     self.season = Season(**kwargs)
     self.season.save()
     return self.season
Example #7
0
    def create_cache(self, type=Cache.LADDER, members=None, **kwargs):
        data = kwargs.pop('data', None)
        if data is None and members is not None:
            data = gen_ladder_data(members)

        kwargs = merge_args(
            {
                'bid': randint(1, 1e6),
                'url': 'http://bnet/' + uniqueid(10),
                'type': type,
                'region': Region.EU,
                'created': utcnow(),
                'updated': utcnow(),
                'status': 200,
                'retry_count': 0
            }, **kwargs)
        kwargs['data'] = json.dumps(data)

        self.cache = Cache(**kwargs)
        self.cache.save()
        return self.cache
Example #8
0
    def create_ladder(self, **kwargs):
        kwargs = merge_args(
            {
                'bid': 1,
                'region': Region.EU,
                'strangeness': Ladder.GOOD,
                'league': League.GOLD,
                'tier': 0,
                'version': Version.HOTS,
                'mode': Mode.TEAM_1V1,
                'season': self.season,
                'first_join': utcnow(),
                'last_join': utcnow(),
                'created': utcnow(),
                'updated': utcnow(),
                'max_points': 20
            }, **kwargs)

        self.ladder = Ladder(**kwargs)
        self.ladder.save()
        return self.ladder