def test_add_one_existing_team(self):
        session = self.setup_basic_test()
        team_repo = TeamRepository()

        name_1 = "Team GA1"
        name_2 = "Team GA2"

        team_repo.add(Team(name_1, 12, True, self.get_id()), session)

        session.commit()

        team_1 = team_repo.get_by_name(name_1, session)
        team_2 = Team(name_2, 12, True, self.get_id())

        self.get_repo().add(Game(1, 15, team_1, team_2, 5, 4, True, False, GameRules("Rules", True, self.get_id()),
                                 self.get_id()), session)
        session.commit()

        g_list = self.get_repo().get_all(session)
        self.assertEqual(1, len(g_list))
    def test_get_my_complete_and_unprocessed(self):
        session = self.setup_basic_test()
        Database.clean_up_database(session)
        team_repo = TeamRepository()
        rules_repo = GameRulesRepository()

        team1 = Team("t1", 5, True, "A")
        team2 = Team("t2", 5, True, "B")
        team_repo.add(team1, session)
        team_repo.add(team2, session)
        gr = GameRules("Rules 12", True, "T")
        rules_repo.add(gr, session)
        session.commit()

        team1 = team_repo.get_by_name("t1", session)
        team2 = team_repo.get_by_name("t2", session)
        gr = rules_repo.get_by_name("Rules 12", session)

        game1 = Game(1, 1, team1, team2, 0, 0, True, False, gr, "1")
        game2 = Game(1, 1, team1, team2, 0, 0, False, False, gr, "2")
        game3 = Game(1, 2, team1, team2, 0, 0, False, False, gr, "3")
        game4 = Game(1, 2, team1, team2, 0, 0, False, False, gr, "4")
        game5 = Game(1, 3, team1, team2, 0, 0, True, False, gr, "5")
        game6 = Game(1, 3, team1, team2, 0, 0, False, False, gr, "6")
        game7 = Game(1, 4, team1, team2, 0, 0, True, False, gr, "7")
        game8 = Game(2, 1, team1, team2, 0, 0, True, False, gr, "8")

        games = [game1, game2, game3, game4, game5, game6, game7, game8]

        [self.get_repo().add(g, session) for g in games]

        session.commit()

        result = list(self.get_repo().get_by_unprocessed_and_complete(1, 1, 4, session))
        self.assertEqual(3, len(result))

        result = list(self.get_repo().get_by_unprocessed_and_complete(1, 1, 2, session))
        self.assertEqual(1, len(result))

        result = list(self.get_repo().get_by_unprocessed_and_complete(2, 1, 25, session))
        self.assertEqual(1, len(result))
    def test_get_first_day_for_game(self):
        session = self.setup_basic_test()
        Database.clean_up_database(session)
        team_repo = TeamRepository()
        rules_repo = GameRulesRepository()

        team1 = Team("t1", 5, True, "A")
        team2 = Team("t2", 5, True, "B")
        team3 = Team("t3", 5, True, "C")
        team4 = Team("t4", 5, True, "D")

        new_teams = [team1, team2, team3, team4]
        [team_repo.add(team, session) for team in new_teams]

        new_gr = GameRules("Rules 12", True, "T")
        rules_repo.add(new_gr, session)
        session.commit()

        gr = rules_repo.get_by_name("Rules 12", session)

        teams = team_repo.get_all(session)

        game1 = Game(1, 5, teams[0], teams[1], 0, 1, True, True, gr, "K")

        games = [game1]

        [self.get_repo().add(game, session) for game in games]

        session.commit()
        # first test, should be none because teams[0] plays on day 5
        game2 = GameDTO(Game(1, -1, teams[0], teams[2], 0, 1, True, True, gr, "L"))
        result = self.get_repo().get_list_days_teams_play_on(1, 1, 100, game2, session)

        self.assertEquals(5, result[0])

        game2.day = 1
        self.get_repo().add(game2, session)
        session.commit()

        result = self.get_repo().get_list_days_teams_play_on(1, 1, 100, game2, session)
        print(result)