def test_user_without_bets(self): self.game.score_team1 = 1 self.game.score_team2 = 0 db.session.commit() update_scores_by_game(self.game)
def test_team1_result(self): self.game.score_team1 = 1 self.game.score_team2 = 0 bet = BetGame(user=self.user, game=self.game, score_team1=2, score_team2=1) db.session.add(bet) db.session.commit() update_scores_by_game(self.game) self.assertEqual(9, bet.score)
def test_exact_draw(self): self.game.score_team1 = 1 self.game.score_team2 = 1 bet = BetGame(user=self.user, game=self.game, score_team1=1, score_team2=1) db.session.add(bet) db.session.commit() update_scores_by_game(self.game) self.assertEqual(18, bet.score)
def test_team2_result_with_score(self): self.game.score_team1 = 0 self.game.score_team2 = 2 bet1 = BetGame(user=self.user, game=self.game, score_team1=1, score_team2=2) bet2 = BetGame(user=self.user2, game=self.game, score_team1=0, score_team2=1) db.session.add(bet1) db.session.add(bet2) db.session.commit() update_scores_by_game(self.game) self.assertEqual(12, bet1.score) self.assertEqual(12, bet2.score)
def test_only_score(self): self.game.score_team1 = 0 self.game.score_team2 = 0 bet1 = BetGame(user=self.user, game=self.game, score_team1=1, score_team2=0) bet2 = BetGame(user=self.user2, game=self.game, score_team1=0, score_team2=1) db.session.add(bet1) db.session.add(bet2) db.session.commit() update_scores_by_game(self.game) self.assertEqual(3, bet1.score) self.assertEqual(3, bet2.score)
def test_team2_result(self): self.game.score_team1 = 0 self.game.score_team2 = 1 bet = BetGame(user=self.user, game=self.game, score_team1=1, score_team2=2) db.session.add(bet) db.session.commit() update_scores_by_game(self.game) self.assertEqual(9, bet.score)
def on_model_change(self, form, model, is_created): if not is_created and model.score_team1 is not None: update_scores_by_game(model) update_ranking() update_positions()