예제 #1
0
    def test_update_semifinal_and_p5(self):
        gameday = DBSetup().g62_qualify_finished()

        info_p5 = Gameinfo.objects.get(standing='P5')
        results_p5 = Gameresult.objects.filter(gameinfo=info_p5)
        assert results_p5[0].team.name == 'A3'
        assert results_p5[1].team.name == 'B3'

        info_semifinals = Gameinfo.objects.filter(standing='HF')
        results_sf1_qs = Gameresult.objects.filter(gameinfo=info_semifinals[0])
        assert results_sf1_qs[0].team.name == 'B2'
        assert results_sf1_qs[1].team.name == 'A1'

        su = ScheduleUpdate(gameday.pk, gameday.format)
        su.update()

        assert results_p5[0].team.name == 'A3'
        assert results_p5[1].team.name == 'B3'

        assert results_sf1_qs[0].team.name == 'B2'
        assert results_sf1_qs[1].team.name == 'A1'

        results_sf2_qs = Gameresult.objects.filter(gameinfo=info_semifinals[1])
        assert results_sf2_qs[0].team.name == 'A2'
        assert results_sf2_qs[1].team.name == 'B1'
예제 #2
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')
예제 #3
0
 def test_officials_update(self):
     gameday = DBSetup().g62_qualify_finished()
     games = Gameinfo.objects.filter(
         standing='HF') | Gameinfo.objects.filter(standing='P5')
     sf1 = 0
     sf2 = 1
     assert games.filter(officials__name__exact='teamName').count() == 3
     su = ScheduleUpdate(gameday.pk, gameday.format)
     su.update()
     assert games[sf1].officials.name == 'B3'
     assert games[sf2].officials.name == 'A3'
     # P5 will be updated, when SF are finished
     assert games.filter(officials__name__exact='teamName').count() == 1
예제 #4
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()
예제 #5
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')
예제 #6
0
def update_game_schedule(sender, instance: Gameinfo, created, **kwargs):
    if instance.status == FINISHED:
        update_schedule = ScheduleUpdate(instance.gameday_id, instance.gameday.format)
        update_schedule.update()
예제 #7
0
 def test_update_qualify_not_finished(self, create_mock: MagicMock):
     gameday = DBSetup().g62_status_empty()
     su = ScheduleUpdate(gameday.pk, gameday.format)
     su.update()
     create_mock.assert_not_called()
예제 #8
0
    def test_update_semifinal_is_not_overridden(self, create_mock: MagicMock):
        gameday = DBSetup().g62_finalround(sf='beendet', p5='beendet')

        su = ScheduleUpdate(gameday.pk, gameday.format)
        su.update()
        assert create_mock.call_count == 4, 'only games for P3 and P1 should be created'