当前位置: 首页>>代码示例>>Python>>正文


Python Team.get_for_country方法代码示例

本文整理汇总了Python中models.team.Team.get_for_country方法的典型用法代码示例。如果您正苦于以下问题:Python Team.get_for_country方法的具体用法?Python Team.get_for_country怎么用?Python Team.get_for_country使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.team.Team的用法示例。


在下文中一共展示了Team.get_for_country方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_populate

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
    def test_populate(self):
        self.assertIsNotNone(self.teams)
        self.assertGreater(len(self.teams), 0)
        self.assertIsNotNone(self.argentina.friendly_results)

        # argentina beat mexico, make sure this is apparent
        self.assertIn(Team.get_for_country(self.teams, 'Mexico'), self.argentina.friendly_results['wins'])
        self.assertIn(self.argentina, Team.get_for_country(self.teams, "Mexico").friendly_results['losses'])

        self.assertIsNotNone(self.cote.friendly_results.get('wins', None))
        self.assertIsNotNone(self.cote.friendly_results.get('losses', None))

        # make sure all teams have at least one win and one loss (draws could possibly be missing)
        for team in self.teams:
            self.assertIsNotNone(len(team.friendly_results.get('wins', None)))
            self.assertIsNotNone(len(team.friendly_results.get('losses', None)))
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:18,代码来源:test_populators.py

示例2: test_add_friendly_result

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
    def test_add_friendly_result(self):
        self.usa.add_friendly_result(opponent=self.brazil)
        self.usa.add_friendly_result(opponent=self.brazil, result=Team.DRAW)
        self.usa.add_friendly_result(opponent=self.brazil, result=Team.LOSS)

        self.assertIn(self.brazil, self.usa.friendly_results['wins'])
        self.assertIn(self.brazil, self.usa.friendly_results['draws'])
        self.assertIn(self.brazil, self.usa.friendly_results['losses'])

        # try adding a friendly result for a team not in the tourney
        prev_draws = len(self.usa.friendly_results['draws'])
        self.usa.add_friendly_result(opponent=Team.get_for_country(self.teams, "Israel"), result=Team.DRAW)
        self.assertEqual(prev_draws + 1, len(self.usa.friendly_results['draws']))
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:15,代码来源:test_models.py

示例3: populate

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
    def populate(self):
        """
        :return: ``list`` the ``teams`` with player information added
        """
        if not self._players_csv_exists():
            self._create_csv_from_webpage()

        teams = self.tournament.teams
        with open(self.csv_path, 'rb') as csvfile:
            reader = csv.reader(csvfile, delimiter=',', quotechar='|')
            for i, row in enumerate(reader):
                team = Team.get_for_country(teams, row[1])
                if team and len(team.players) <= self.num_players_allowed:
                    # since the players are sorted by skill level, we say the best 20 players are stars
                    new_player = Player(name=row[0], age=row[2], skill_rank=int(row[3]), is_star=i < 20)
                    team.players.append(new_player)

        return teams
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:20,代码来源:players_populator.py

示例4: _set_friendly_results

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
    def _set_friendly_results(self):
        """
        populate the friendly_results hash for each team from results.csv
        """
        with open('data/results.csv') as results_csv:
            reader = csv.reader(results_csv)
            for result in reader:
                get_team = lambda index: Team.get_for_country(self.tournament.teams, result[index].strip())
                home_team, away_team = get_team(1), get_team(2)
                home_goals, away_goals = result[3], result[4]

                try:
                    home_team.add_friendly_result(opponent=away_team, result=home_team.result_from_scores(home_goals,
                                                                                                          away_goals))
                except AttributeError:
                    # either the header row or the away / home team isn't in the tourney
                    pass
                try:
                    away_team.add_friendly_result(opponent=home_team, result=away_team.result_from_scores(away_goals,
                                                                                                          home_goals))
                except AttributeError:
                    # either the header row or the away team isn't in the tourney
                    pass
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:25,代码来源:teams_populator.py

示例5: test_get_opponent_at_stage

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
    def test_get_opponent_at_stage(self):
        brazil = Team.get_for_country(self.teams, 'Brazil')
        mexico = Team.get_for_country(self.teams, 'Mexico')
        cameroon = Team.get_for_country(self.teams, 'Cameroon')
        spain = Team.get_for_country(self.teams, 'Spain')
        netherlands = Team.get_for_country(self.teams, 'Netherlands')

        opp = self.tree.get_opponent_at_stage(brazil, 0)
        self.assertEqual(opp.country, netherlands.country)
        opp = self.tree.get_opponent_at_stage(brazil, 1)
        self.assertEqual(opp.country, Team.get_for_country(self.teams, 'Colombia').country)
        opp = self.tree.get_opponent_at_stage(brazil, 3)
        self.assertEqual(opp.country, spain.country)

        opp = self.tree.get_opponent_at_stage(netherlands, 0)
        self.assertEqual(opp.country, brazil.country)

        opp = self.tree.get_opponent_at_stage(mexico, 0)
        self.assertEqual(opp.country, spain.country)

        # test for a team that isn't in the probability tree
        self.assertEqual(self.tree.get_opponent_at_stage(cameroon, 0).country, self.tree.get_opponent_at_stage(mexico, 0).country)
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:24,代码来源:test_models.py

示例6: setUp

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
 def setUp(self):
     self.tournament = Tournament()
     self.teams = self.tournament.teams
     self.usa = Team.get_for_country(self.teams, 'United States')
     self.brazil = Team.get_for_country(self.teams, 'Brazil')
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:7,代码来源:test_models.py

示例7: test_get_for_group

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
 def test_get_for_group(self):
     self.assertIn(Team.get_for_country(self.teams, 'Brazil'), Team.get_for_group(self.teams, 'A'))
     self.assertNotIn(Team.get_for_country(self.teams, 'Brazil'), Team.get_for_group(self.teams, 'B'))
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:5,代码来源:test_models.py

示例8: test_get_for_country

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
 def test_get_for_country(self):
     self.assertEqual(Team.get_for_country(self.teams, 'Brazil').country, 'Brazil')
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:4,代码来源:test_models.py

示例9: test_base_score

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
 def test_base_score(self):
     # these tests operate using some basic, commonly held assumptions (which could actually be a source of human error)
     self.assertGreater(self.brazil.base_score, self.usa.base_score)
     self.assertGreater(self.usa.base_score, Team.get_for_country(self.teams, "Ghana").base_score)
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:6,代码来源:test_models.py

示例10: setUp

# 需要导入模块: from models.team import Team [as 别名]
# 或者: from models.team.Team import get_for_country [as 别名]
 def setUp(self):
     self.tournament = Tournament()
     self.teams = self.tournament.teams
     self.argentina = Team.get_for_country(self.teams, 'Argentina')
开发者ID:steinbachr,项目名称:world-cup-challenge,代码行数:6,代码来源:test_populators.py


注:本文中的models.team.Team.get_for_country方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。