本文整理汇总了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)))
示例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']))
示例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
示例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
示例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)
示例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')
示例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'))
示例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')
示例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)
示例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')