Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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
Example #5
0
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