예제 #1
0
 def last_join(self):
     """ Returns the last join ladder time in  this ladder. """
     members = self.get()
     if not members:
         return None
     if self.gd:
         return from_unix(max(t.get('join_time_stamp', 0) for t in members))
     else:
         return from_unix(max(m['joinTimestamp'] for m in members))
예제 #2
0
    def test_parsing_of_4v4_ladder_works(self):
        al = ApiLadder(API_LADDER_4V4)

        self.assertEqual(from_unix(1479927625), al.first_join())
        self.assertEqual(from_unix(1479927625), al.last_join())
        self.assertEqual(4, al.member_count())
        self.assertEqual(0, al.max_points())
        self.assertEqual([{
            'join_time': 1479927625,
            'bid': 897866,
            'realm': 1,
            'name': 'AaxeoiS',
            'tag': '',
            'clan': '',
            'race': Race.TERRAN,
            'points': 0,
            'mmr': 3965,
            'wins': 4,
            'losses': 1,
        }, {
            'join_time': 1479927625,
            'bid': 1048851,
            'realm': 1,
            'name': 'Hodn',
            'tag': '',
            'clan': '',
            'race': Race.RANDOM,
            'points': 0,
            'mmr': 3965,
            'wins': 4,
            'losses': 1,
        }, {
            'join_time': 1479927625,
            'bid': 1371993,
            'realm': 1,
            'name': 'Tsakal',
            'tag': 'GROF',
            'clan': 'Greek Operation Forces',
            'race': Race.ZERG,
            'points': 0,
            'mmr': 3965,
            'wins': 4,
            'losses': 1,
        }, {
            'join_time': 1479927625,
            'bid': 2972548,
            'realm': 1,
            'name': 'sakis',
            'tag': 'munaki',
            'clan': 'munaki',
            'race': Race.RANDOM,
            'points': 0,
            'mmr': 3965,
            'wins': 4,
            'losses': 1,
        }], al.members_for_ranking(4))
예제 #3
0
    def test_skips_empty_member(self):
        l = deepcopy(API_LADDER_1V1)
        l['team'][0]['member'] = []
        al = ApiLadder(l)

        self.assertEqual(from_unix(1479018088), al.first_join())
        self.assertEqual(from_unix(1479018088), al.last_join())
        self.assertEqual(0, al.member_count())
        self.assertEqual(381, al.max_points())
        self.assertEqual([], al.members_for_ranking(1))
예제 #4
0
    def set_data_time(self, season, cpp):
        """ Calculate and set data_times based off actual data and season. """

        self.min_data_time, self.max_data_time = [from_unix(d) for d in cpp.min_max_data_time()]
        if not self.min_data_time and not self.max_data_time:
            self.min_data_time = self.max_data_time = self.data_time = season.start_time()

        if season.is_open():
            self.data_time = self.max_data_time
        else:
            self.data_time = min(self.max_data_time, season.end_time())
예제 #5
0
    def test_parsing_of_1v1_ladder_works(self):
        al = ApiLadder(API_LADDER_1V1)

        self.assertEqual(from_unix(1479018088), al.first_join())
        self.assertEqual(from_unix(1479018088), al.last_join())
        self.assertEqual(1, al.member_count())
        self.assertEqual(381, al.max_points())
        self.assertEqual([{
            'join_time': 1479018088,
            'bid': 6205328,
            'realm': 1,
            'name': 'peimon',
            'tag': 'Partha',
            'clan': 'boom boom long time',
            'points': 381,
            'mmr': 2136,
            'wins': 12,
            'losses': 24,
            'race': Race.PROTOSS,
        }], al.members_for_ranking(1))
예제 #6
0
    def test_parsing_of_1v1_legacy_ladder_works(self):
        al = ApiLadder(LEGACY_API_LADDER_1V1)

        self.assertEqual(from_unix(1468138637), al.first_join())
        self.assertEqual(from_unix(1468138637), al.last_join())
        self.assertEqual(1, al.member_count())
        self.assertEqual(101, al.max_points())
        self.assertEqual([{
            'join_time': 1468138637,
            'bid': 6061640,
            'realm': 1,
            'name': 'QueenOFpaiN',
            'tag': 'PIN',
            'clan': 'Pain',
            'race': Race.ZERG,
            'points': 101.0,
            'mmr': NO_MMR,
            'wins': 4,
            'losses': 1,
        }], al.members_for_ranking(1))
예제 #7
0
 def start_date(self):
     return from_unix(self.data['start_timestamp']).date()
예제 #8
0
 def start_date(self):
     return from_unix(int(self.data['startDate'])).date()
예제 #9
0
    def test_parsing_of_4v4_legacy_ladder_works(self):
        al = ApiLadder(LEGACY_API_LADDER_4V4)

        self.assertEqual(from_unix(1478313972), al.first_join())
        self.assertEqual(from_unix(1478313972), al.last_join())
        self.assertEqual(4, al.member_count())
        self.assertEqual(0.0, al.max_points())
        self.assertEqual([
            {
                'join_time': 1478313972,
                'bid': 6539206,
                'realm': 1,
                'name': 'Maximus',
                'tag': '',
                'clan': '',
                'race': Race.PROTOSS,
                'points': 0.0,
                'mmr': NO_MMR,
                'wins': 0,
                'losses': 5,
            },
            {
                'join_time': 1478313972,
                'bid': 6714244,
                'realm': 1,
                'name': 'Herakles',
                'tag': '',
                'clan': '',
                'race': Race.TERRAN,
                'points': 0.0,
                'mmr': NO_MMR,
                'wins': 0,
                'losses': 5,
            },
            {
                'join_time': 1478313972,
                'bid': 6718054,
                'realm': 1,
                'name': 'Amazone',
                'tag': '',
                'clan': '',
                'race': Race.TERRAN,
                'points': 0.0,
                'mmr': NO_MMR,
                'wins': 0,
                'losses': 5,
            },
            {
                'join_time': 1478313972,
                'bid': 6742389,
                'realm': 1,
                'name': 'philipp',
                'tag': 'TAG',
                'clan': 'CLAN',
                'race': Race.ZERG,
                'points': 0.0,
                'mmr': NO_MMR,
                'wins': 0,
                'losses': 5,
            },
        ], al.members_for_ranking(4))