Example #1
0
    def test_update_7_teams_2_fields(self):
        gameday = DBSetup().create_empty_gameday()
        gameday.format = "7_2"
        gameday.save()
        group_B = DBSetup().create_teams('B', 3)
        group_A = DBSetup().create_teams('A', 4)
        groups = [group_A, group_B]
        DBSetup().create_playoff_placeholder_teams()
        sc = ScheduleCreator(gameday=Gameday.objects.get(pk=gameday.pk),
                             schedule=Schedule(gameday.format, groups))
        sc.create()

        Gameinfo.objects.filter(stage='Vorrunde').update(status='beendet')
        finished_games = Gameinfo.objects.filter(status='beendet')
        for game in finished_games:
            update_gameresults(game)
        su = ScheduleUpdate(gameday.pk, gameday.format)
        su.update()
        update_gameresults_by_standing_and_finish_game_for('HF')
        su.update()

        p5_first = Gameinfo.objects.filter(standing__in=['P5-1', 'P3'])
        for game in p5_first:
            update_gameresults(game)
        p5_first.update(status='beendet')
        su = ScheduleUpdate(gameday.pk, gameday.format)
        su.update()

        p5_first = Gameinfo.objects.filter(standing__in=['P5-2', 'P1'])
        for game in p5_first:
            update_gameresults(game)
        p5_first.update(status='beendet')
Example #2
0
    def test_update_9_teams_3_fields(self):
        gameday = DBSetup().create_empty_gameday()
        gameday.format = "9_3"
        gameday.save()
        group_A = DBSetup().create_teams('A', 3)
        group_B = DBSetup().create_teams('B', 3)
        group_C = DBSetup().create_teams('C', 3)
        groups = [group_A, group_B, group_C]
        DBSetup().create_playoff_placeholder_teams()
        sc = ScheduleCreator(gameday=Gameday.objects.get(pk=gameday.pk),
                             schedule=Schedule(gameday.format, groups))
        sc.create()

        qualify_games = Gameinfo.objects.filter(stage='Vorrunde')
        for game in qualify_games:
            update_gameresults(game)
        Gameinfo.objects.filter(stage='Vorrunde').update(status='beendet')

        su = ScheduleUpdate(gameday.pk, gameday.format)
        su.update()
        check_if_first_standing('PO').is_updated_as_expected_with(
            'B2', 'C2', 'C3')
        check_if_first_standing('P7').is_updated_as_expected_with(
            'A1', 'B1', 'B3')

        update_gameresults_by_standing_and_finish_game_for('PO')
        update_gameresults_and_finish_first_game_for_P7()
        su.update()
        check_if_first_standing('HF').is_updated_as_expected_with(
            'C2', 'C3', 'B2')
        check_if_first_standing('P7').is_updated_as_expected_with(
            'B1', 'C1', 'A2')
        check_if_first_standing('P5').is_updated_as_expected_with(
            'A2', 'B2', 'B1')

        update_gameresults_by_standing_and_finish_game_for('HF')
        update_gameresults_and_finish_first_game_for_P7()
        su.update()
        check_if_first_standing('P7').is_updated_as_expected_with(
            'C1', 'A1', 'C2')
        check_if_first_standing('P1').is_updated_as_expected_with(
            'B3', 'C3', 'A1')
        check_if_first_standing('P3').is_updated_as_expected_with(
            'A3', 'C2', 'C1')

        update_gameresults_by_standing_and_finish_game_for('P5')
        update_gameresults_and_finish_first_game_for_P7()
        update_gameresults_by_standing_and_finish_game_for('P3')
        update_gameresults_by_standing_and_finish_game_for('P1')

        gmw = GamedayModelWrapper(gameday.pk)
        DataFrameAssertion.expect(
            gmw.get_final_table()).to_equal_json('final_table_9_teams.json')
        DataFrameAssertion.expect(
            gmw.get_schedule()).to_equal_json('schedule_9_teams_3_fields.json')
Example #3
0
    def test_update_less_than_5_teams_dont_throws_error(self):
        gameday = DBSetup().create_empty_gameday()
        gameday.format = "5_2"
        gameday.save()
        group_A = DBSetup().create_teams('A', 5)
        groups = [group_A]
        DBSetup().create_playoff_placeholder_teams()
        sc = ScheduleCreator(gameday=Gameday.objects.get(pk=gameday.pk),
                             schedule=Schedule(gameday.format, groups))
        sc.create()

        Gameinfo.objects.filter(stage='Hauptrunde').update(status='beendet')
        finished_games = Gameinfo.objects.filter(status='beendet')
        for game in finished_games:
            update_gameresults(game)
        su = ScheduleUpdate(gameday.pk, gameday.format)
        su.update()
Example #4
0
 def test_secondhalf_is_played(self):
     firstGameEntry = DBSetup().create_teamlog_home_and_away()
     firstGameEntry.gameHalftime = '09:57'
     firstGameEntry.save()
     gamelog = GameLog(firstGameEntry)
     assert not gamelog.is_firsthalf()