Ejemplo n.º 1
0
 def test_head_to_head(self):
     test_matches = []
     for match in head_to_head:
         test_matches.append(Match(match['teams'], match['week'], match['result']))
     lec = LEC.from_matches(test_matches)
     lec.create_standings()
     self.assertIn('OG', lec.standings[1])
     self.assertIn('G2', lec.standings[1])
     self.assertIn('FNC', lec.standings[1])
Ejemplo n.º 2
0
 def test_wins_in_second_half(self):
     test_matches = []
     for match in wins_in_second_half:
         test_matches.append(Match(match['teams'], match['week'], match['result']))
     lec = LEC.from_matches(test_matches)
     lec.create_standings()
     self.assertIn('FNC', lec.standings[1])
     self.assertIn('OG', lec.standings[2])
     self.assertIn('G2', lec.standings[3])
Ejemplo n.º 3
0
    def test_get_wins(self):
        matches = Match.from_json('src/tests/lec_test_matches.json')
        lec = LEC.from_matches(matches)
        rge_wins = lec.teams['RGE'].get_wins()
        g2_wins = lec.teams['G2'].get_wins()
        s04_wins = lec.teams['S04'].get_wins()

        self.assertEqual(rge_wins, 11)
        self.assertEqual(g2_wins, 8)
        self.assertEqual(s04_wins, 5)
Ejemplo n.º 4
0
 def test_create_table_one_day(self):
     test_matches = []
     for match in matches_one_day:
         test_matches.append(Match(match['teams'], match['week'], match['result']))
     lec = LEC.from_matches(test_matches)
     lec.create_table()
     self.assertEqual(lec.table['XL'], 1)
     self.assertEqual(lec.table['VIT'], 1)
     self.assertEqual(lec.table['S04'], 1)
     self.assertEqual(lec.table['RGE'], 1)
     self.assertEqual(lec.table['MAD'], 1)
 def __init__(self, League: League):
     matches = Match.from_json(League.matches_file)
     self.finished_matches = []
     self.upcomming_matches = []
     self.cumulated_outcomes = {}
     self.League = League
     for match in matches:
         if match.result:
             self.finished_matches.append(match)
         else:
             self.upcomming_matches.append(match)
Ejemplo n.º 6
0
 def test_create_table_season(self):
     matches = Match.from_json('src/tests/lec_test_matches.json')
     lec = LEC.from_matches(matches)
     lec.create_table()
     self.assertEqual(lec.table['RGE'], 11)
     self.assertEqual(lec.table['MAD'], 11)
     self.assertEqual(lec.table['XL'], 7)
     self.assertEqual(lec.table['VIT'], 6)
     self.assertEqual(lec.table['S04'], 5)
     self.assertEqual(lec.table['OG'], 6)
     self.assertEqual(lec.table['FNC'], 7)
     self.assertEqual(lec.table['SK'], 8)
     self.assertEqual(lec.table['G2'], 8)
     self.assertEqual(lec.table['MSF'], 6)
Ejemplo n.º 7
0
 def test_create_standings_season(self):
     matches = Match.from_json('src/tests/lec_test_matches.json')
     lec = LEC.from_matches(matches)
     lec.create_standings()
     self.assertIn('XL', lec.standings[6])
     self.assertIn('VIT', lec.standings[7])
     self.assertIn('S04', lec.standings[10])
     self.assertIn('RGE', lec.standings[2])
     self.assertIn('MAD', lec.standings[1])
     self.assertIn('SK', lec.standings[3])
     self.assertIn('OG', lec.standings[9])
     self.assertIn('G2', lec.standings[4])
     self.assertIn('MSF', lec.standings[8])
     self.assertIn('FNC', lec.standings[5])
Ejemplo n.º 8
0
 def test_create_standings_one_day(self):
     test_matches = []
     for match in matches_one_day:
         test_matches.append(Match(match['teams'], match['week'], match['result']))
     lec = LEC.from_matches(test_matches)
     lec.create_standings()
     self.assertIn('XL', lec.standings[1])
     self.assertIn('VIT', lec.standings[1])
     self.assertIn('S04', lec.standings[1])
     self.assertIn('RGE', lec.standings[1])
     self.assertIn('MAD', lec.standings[1])
     self.assertIn('SK', lec.standings[6])
     self.assertIn('OG', lec.standings[6])
     self.assertIn('G2', lec.standings[6])
     self.assertIn('MSF', lec.standings[6])
     self.assertIn('FNC', lec.standings[6])
Ejemplo n.º 9
0
    def _get_matches(self):
        response = requests.get(self.lec_gamepedia_url)
        soup = BeautifulSoup(response.content, self.default_beautifulsoup_parser)

        wiki_tables = soup.find_all('table', class_='wikitable2 matchlist')
        for wiki_table in wiki_tables:
            week = wiki_table.find('th').get_text()
            week_pattern = re.compile('\d')
            week = week_pattern.findall(week)[0]
            matches_row = wiki_table.find_all('tr', class_='ml-row')
            for match in matches_row:
                teams_html = match.find_all('span', class_='teamname')
                teams = [team.get_text() for team in teams_html]
                result_html = match.find_all('td', class_='matchlist-score')
                result = [int(result.get_text()) for result in result_html]
                self.matches.append(Match(teams, int(week), result))
Ejemplo n.º 10
0
 def test_get_winner_right(self):
     match = Match(['Loser', 'Winner'], 0, [0, 1])
     self.assertEqual(match.get_winner(), 'Winner')
Ejemplo n.º 11
0
 def test_get_winner_left(self):
     match = Match(['Winner', 'Loser'], 0, [1, 0])
     self.assertEqual(match.get_winner(), 'Winner')
Ejemplo n.º 12
0
 def test_get_winner_no_result(self):
     match = Match(['Loser', 'Winner'], 0)
     self.assertIsNone(match.get_winner())