Ejemplo n.º 1
0
    def test_teams_standings(self):
        teams, matches = self.__gen_matches__()
        league = League(u'Süper Lig')

        for m in matches:
            league.add_match(m)

        standings = league.get_league_table
        self.assertEqual(standings, [{
            u'position': 1,
            u'points': 14,
            u'team': u'Ankaragücü'
        }, {
            u'position': 2,
            u'points': 8,
            u'team': u'Gençlerbirliği'
        }, {
            u'position': 2,
            u'points': 8,
            u'team': u'Kasımpaşa'
        }, {
            u'position': 4,
            u'points': 2,
            u'team': u'Feriköy'
        }])
Ejemplo n.º 2
0
    def test_calc_standings(self):
        home = Team(u'TOP Oss')
        away = Team(u'Go Ahead Eagles')
        m = Match(home, 0, away, 3)
        l = League(u'Eerste Divisie')

        match_outcome = l.__calc_league_stats__(m)
        self.assertEqual(match_outcome, [{
            u'goals_for': 0,
            u'won': 0,
            u'goals_against': 3,
            u'lost': 1,
            u'team': home,
            u'played': 1,
            u'drew': 0,
            u'points': 0
        }, {
            u'goals_for': 3,
            u'won': 1,
            u'goals_against': 0,
            u'lost': 0,
            u'team': away,
            u'played': 1,
            u'drew': 0,
            u'points': 3
        }])
Ejemplo n.º 3
0
    def test_add_match(self):
        teams, matches = self.__gen_matches__()
        league = League(u'Süper Lig')

        for m in matches:
            league.add_match(m)

        self.assertEqual(len(league.matches), 12)
        self.assertEqual(len(league.teams), 4)
Ejemplo n.º 4
0
    def test_add_match(self):
        teams, matches = self.__gen_matches__()
        league = League(u'Süper Lig')

        for m in matches:
            league.add_match(m)

        self.assertEqual(len(league.matches), 12)
        self.assertEqual(len(league.teams), 4)
Ejemplo n.º 5
0
    def test_incomplete_standings(self):
        l = League(u'Lega Procrastica')
        home = Team(u'Anubis Incompeta')
        away = Team(u'Doitus Latero')
        m = Match(home, 0, away, 0)
        l.add_match(m)

        standings = l.get_league_table
        self.assertEqual(
            standings,
            [
                {u'points': 1, u'position': 1, u'team': u'Anubis Incompeta'},
                {u'points': 1, u'position': 1, u'team': u'Doitus Latero'},
            ]
        )
Ejemplo n.º 6
0
    def test_calc_standings(self):
        home = Team(u'TOP Oss')
        away = Team(u'Go Ahead Eagles')
        m = Match(home, 0, away, 3)
        l = League(u'Eerste Divisie')

        match_outcome = l.__calc_league_stats__(m)
        self.assertEqual(
            match_outcome,
            [
                {u'goals_for': 0, u'won': 0, u'goals_against': 3, u'lost': 1, u'team': home,
                 u'played': 1, u'drew': 0, u'points': 0},
                {u'goals_for': 3, u'won': 1, u'goals_against': 0, u'lost': 0, u'team': away,
                 u'played': 1, u'drew': 0, u'points': 3}
            ])
Ejemplo n.º 7
0
    def test_teams_standings(self):
        teams, matches = self.__gen_matches__()
        league = League(u'Süper Lig')

        for m in matches:
            league.add_match(m)

        standings = league.get_league_table
        self.assertEqual(
            standings,
            [
                {u'position': 1, u'points': 14, u'team': u'Ankaragücü'},
                {u'position': 2, u'points': 8, u'team': u'Gençlerbirliği'},
                {u'position': 2, u'points': 8, u'team': u'Kasımpaşa'},
                {u'position': 4, u'points': 2, u'team': u'Feriköy'}
            ]
        )
Ejemplo n.º 8
0
    def test_incomplete_standings(self):
        l = League(u'Lega Procrastica')
        home = Team(u'Anubis Incompeta')
        away = Team(u'Doitus Latero')
        m = Match(home, 0, away, 0)
        l.add_match(m)

        standings = l.get_league_table
        self.assertEqual(standings, [
            {
                u'points': 1,
                u'position': 1,
                u'team': u'Anubis Incompeta'
            },
            {
                u'points': 1,
                u'position': 1,
                u'team': u'Doitus Latero'
            },
        ])
Ejemplo n.º 9
0
    def test_parse(self):
        mp = match_parser.MatchParser()
        l = League('Futbolico')

        l.add_match(mp.parse(u'Lions 3, Snakes 3'))
        l.add_match(mp.parse(u'Tarantulas 1, FC Awesome 0'))
        l.add_match(mp.parse(u'Lions 1, FC Awesome 1'))
        l.add_match(mp.parse(u'Tarantulas 3, Snakes 1'))
        l.add_match(mp.parse(u'Lions 4, Grouches 0'))

        self.assertEqual(
            l.get_league_table,
            [
                {u'points': 6, u'position': 1, u'team': u'Tarantulas'},
                {u'points': 5, u'position': 2, u'team': u'Lions'},
                {u'points': 1, u'position': 3, u'team': u'FC Awesome'},
                {u'points': 1, u'position': 3, u'team': u'Snakes'},
                {u'points': 0, u'position': 5, u'team': u'Grouches'}
            ]
        )
Ejemplo n.º 10
0
    def test_parse_nonsense(self):
        mp = match_parser.MatchParser()
        l = League(u'Futbolico')

        with self.assertRaises(ValueError):
            l.add_match(mp.parse(u'No football for you!'))
Ejemplo n.º 11
0
 def test_create_league(self):
     l = League(u'Süper Lig')
     self.assertEqual(l.league_name, u'Süper Lig')
Ejemplo n.º 12
0
    def test_no_teams_standings(self):
        l = League(u'League of Sorrow')

        standings = l.get_league_table
        self.assertEqual(standings, [])
Ejemplo n.º 13
0
    def test_parse(self):
        mp = match_parser.MatchParser()
        l = League('Futbolico')

        l.add_match(mp.parse(u'Lions 3, Snakes 3'))
        l.add_match(mp.parse(u'Tarantulas 1, FC Awesome 0'))
        l.add_match(mp.parse(u'Lions 1, FC Awesome 1'))
        l.add_match(mp.parse(u'Tarantulas 3, Snakes 1'))
        l.add_match(mp.parse(u'Lions 4, Grouches 0'))

        self.assertEqual(l.get_league_table, [{
            u'points': 6,
            u'position': 1,
            u'team': u'Tarantulas'
        }, {
            u'points': 5,
            u'position': 2,
            u'team': u'Lions'
        }, {
            u'points': 1,
            u'position': 3,
            u'team': u'FC Awesome'
        }, {
            u'points': 1,
            u'position': 3,
            u'team': u'Snakes'
        }, {
            u'points': 0,
            u'position': 5,
            u'team': u'Grouches'
        }])
Ejemplo n.º 14
0
    def test_parse_nonsense(self):
        mp = match_parser.MatchParser()
        l = League(u'Futbolico')

        with self.assertRaises(ValueError):
            l.add_match(mp.parse(u'No football for you!'))