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


Python Player.id方法代码示例

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


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

示例1: test_standings_with_games_not_played

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import id [as 别名]
def test_standings_with_games_not_played(g):
    p = Player("test player")
    p2 = Player("test player 2")
    p3 = Player("test player 3")
    player_dao.create(p)
    p.id = 1
    player_dao.create(p2)
    p2.id = 2
    player_dao.create(p3)
    p3.id = 3
    t = Tournament(0,'','T1','type',0)
    tournament_dao.create(t)
    t.id = 1
    match_dao.create([p.id, p2.id], t.id)
    match_dao.create([p.id, p3.id], t.id)
    match_dao.create([p3.id, p2.id], t.id)

    standings = standings_dao.find(t.id)

    assert standings[0].win == 0
    assert standings[0].loss == 0
    assert standings[0].tie == 0
    assert standings[1].win == 0
    assert standings[1].loss == 0
    assert standings[1].tie == 0
    assert standings[2].win == 0
    assert standings[2].loss == 0
    assert standings[2].tie == 0
开发者ID:ewilson,项目名称:tournament,代码行数:30,代码来源:standings_dao_test.py

示例2: test_undo_match

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import id [as 别名]
def test_undo_match(g):
    p = Player("test player")
    p2 = Player("test player 2")
    player_dao.create(p)
    p.id = 1
    player_dao.create(p2)
    p2.id = 2
    t = Tournament(0,'','T1','type',0)
    tournament_dao.create(t)
    t.id = 1
    match_dao.create([p.id, p2.id], t.id)
    match_id = 1
    match = Match(player1=p,player2=p2,id=match_id)
    match.score1 = 19
    match.score2 = 21
    match_dao.update(match)

    match_dao.undo(match)
    retrieved_match = match_dao.find(match_id)
    matches = match_dao.find_by_tournament(t.id)

    assert retrieved_match.score1 == 0
    assert retrieved_match.score2 == 0
    assert retrieved_match.player1.fname == p.fname
    assert retrieved_match.player2.fname == p2.fname
    assert retrieved_match.player1.id == p.id
    assert retrieved_match.player2.id == p2.id
    assert not matches[0].entered_time
开发者ID:ewilson,项目名称:tournament,代码行数:30,代码来源:match_dao_test.py

示例3: test_create_and_find_scheduled_by_tournament

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import id [as 别名]
def test_create_and_find_scheduled_by_tournament(g):
    p = Player("test player")
    p2 = Player("test player 2")
    p3 = Player("test player 3")
    player_dao.create(p)
    p.id = 1
    player_dao.create(p2)
    p2.id = 2
    player_dao.create(p3)
    p3.id = 3
    t = Tournament(0,'','T1','type',0)
    tournament_dao.create(t)
    t.id = 1
    t2 = Tournament(0,'','T2','type',0)
    tournament_dao.create(t2)
    t2.id = 2

    match_dao.create([p.id,p2.id], t.id)
    match_dao.create([p.id,p2.id], t2.id)
    match_dao.create([p.id,p3.id], t2.id)
    retrieved_matches = match_dao.find_by_tournament(t2.id)

    assert len(retrieved_matches) == 2
    assert retrieved_matches[0].player2.fname == p2.fname
    assert retrieved_matches[1].id == 3
开发者ID:ewilson,项目名称:tournament,代码行数:27,代码来源:match_dao_test.py

示例4: test_create_and_find_match

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import id [as 别名]
def test_create_and_find_match(g):
    p = Player("test player")
    p2 = Player("test player 2")
    player_dao.create(p)
    p.id = 1
    player_dao.create(p2)
    p2.id = 2
    t = Tournament(0,'','T1','type',0)
    tournament_dao.create(t)
    t.id = 1

    match_dao.create([p.id, p2.id], t.id)
    retrieved_match = match_dao.find(1)

    assert retrieved_match.id == 1
    assert retrieved_match.player1.fname == p.fname
    assert retrieved_match.player2.fname == p2.fname
开发者ID:ewilson,项目名称:tournament,代码行数:19,代码来源:match_dao_test.py

示例5: test_standings

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import id [as 别名]
def test_standings(g):
    p = Player("test player")
    p2 = Player("test player 2")
    p3 = Player("test player 3")
    player_dao.create(p)
    p.id = 1
    player_dao.create(p2)
    p2.id = 2
    player_dao.create(p3)
    p3.id = 3
    t = Tournament(0,'','T1','type',0)
    tournament_dao.create(t)
    t.id = 1
    match_dao.create([p.id, p2.id], t.id)
    match_dao.create([p.id, p3.id], t.id)
    match_dao.create([p3.id, p2.id], t.id)
    match = Match(player1=p,player2=p2,id=1)
    match.score1 = 19
    match.score2 = 21
    match2 = Match(player1=p,player2=p3,id=2)
    match2.score1 = 17
    match2.score2 = 21
    match3 = Match(player1=p3,player2=p2,id=3)
    match3.score1 = 23
    match3.score2 = 21

    match_dao.update(match)
    match_dao.update(match2)
    match_dao.update(match3)
    standings = standings_dao.find(t.id)

    assert standings[0].name == p.fname
    assert standings[0].win == 0
    assert standings[0].loss == 2
    assert standings[1].name == p2.fname
    assert standings[1].win == 1
    assert standings[1].loss == 1
    assert standings[2].name == p3.fname
    assert standings[2].win == 2
    assert standings[2].loss == 0
开发者ID:ewilson,项目名称:tournament,代码行数:42,代码来源:standings_dao_test.py

示例6: update_players

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import id [as 别名]
def update_players():
    '''
    Updates the Player table with the json retrieved from Kimono.
    If a player is not in the table it creates one.
    Returns the number of new palyers added to the db
    '''
    logger.info('Updating players...')
    url = settings.KIMONO['players_url']
    players = _get_results_collection1(url)
    logger.info(' - Updating database...')
    no_new_players = 0
    for player in players:
        p = Player()
        # If the player is already in the db, using the same pk end up updating
        # the past value
        p.id = _id_from_url(player['name']['href'])
        if not Player.objects.filter(pk=p.id).exists():
            no_new_players += 1
        p.name = player['name']['text']
        p.role = _fix_role(player['role'])
        p.team = Team.objects.get(name__iexact=player['team'])
        p.price = player['price']
        # Replacing the '-' character with 0 in remaining fields
        p.attendances = _fix_zero(player['attendances'])
        p.gol = _fix_zero(player['gol'])
        p.assist = _fix_zero(player['assist'])
        p.yellow_cards = _fix_zero(player['yellow_cards'])
        p.red_cards = _fix_zero(player['red_cards'])
        p.penalties_kicked = _fix_zero(player['penalties_kicked'])
        p.penalties_scored = _fix_zero(player['penalties_scored'])
        p.penalties_missed = _fix_zero(player['penalties_missed'])
        p.penalties_saved = _fix_zero(player['penalties_saved'])
        p.vote_avg = _fix_zero(player['vote_avg'])
        p.magicvote_avg = _fix_zero(player['magicvote_avg'])
        # Storing on the db
        p.save()
    return no_new_players
开发者ID:brescia123,项目名称:fg-backend,代码行数:39,代码来源:db_manager.py


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