本文整理汇总了Python中models.Match.score2方法的典型用法代码示例。如果您正苦于以下问题:Python Match.score2方法的具体用法?Python Match.score2怎么用?Python Match.score2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Match
的用法示例。
在下文中一共展示了Match.score2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_undo_match
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import score2 [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
示例2: test_standings
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import score2 [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
示例3: find
# 需要导入模块: from models import Match [as 别名]
# 或者: from models.Match import score2 [as 别名]
def find(id):
select = """
select p.fname, p.id, a.score, m.entered_time
from player p, attempt a, match m
where p.id = a.player_id
and a.match_id = ?
and m.id = a.match_id
"""
m = Match(id=id)
cur = g.db.execute(select, [id])
attempts = cur.fetchall()
player1 = Player(*attempts[0][:2])
m.player1 = player1
m.score1 = attempts[0][2]
player2 = Player(*attempts[1][:2])
m.player2 = player2
m.score2 = attempts[1][2]
m.entered_time = attempts[0][-1]
return m