Beispiel #1
0
    def test_block_schedule_update(self):
        date = '2019-09-27'
        mtg = get_meeting_for_date(date)
        couples = Scheduler.get_couples(mtg)

        result = Scheduler.update_schedule(date, couples)
        new_couples = Scheduler.get_couples(mtg)
        self.assertEqual(couples, new_couples)
        pass
    def post(self, request, date=None):
        couples = request.data.get('couples')
        result = {'status': "Did not execute"}

        if couples:
            tb = Scheduler()
            result['status'] = tb.update_schedule(date, couples)
            mgr = TeamManager()
            mgr.dbTeams.delete_matchup(date)
        else:
            result['status'] = "Did not decode the guys and gals"
        return Response(result)
    def test_initial_update(self):
        """
        Build structure of couples:
            couple: {'guy':
                        {'id': Player.pk, 'issub': Boolean, 'verified': Boolean},
                     'gal':
                        {'id': Player.pk, 'issub': Boolean, 'verified': Boolean},
                    }
            couples is array of couple
        :return:
        """
        meeting = self.meetings[0]
        couples = self.build_couples()
        scheduler = Scheduler()
        date = meeting.date.strftime("%Y-%m-%d")
        scheduler.update_schedule(date, couples)

        sch = Schedule.objects.filter(meeting=meeting).all()
        self.assertEqual(len(sch), len(couples) * 2)
        self.assertEqual(ScheduleVerify.objects.all().count(), 0)

        for s in sch:
            v = s.get_verification()

        self.assertEqual(len(couples) * 2,
                         ScheduleVerify.objects.all().count(),
                         f'Verify object count should have been {len(couples) * 2}')

        self.assertEqual(len(couples) * 2,
                         ScheduleVerify.objects.filter(sent_on__isnull=True).count(),
                         f'Verify object sent count should have been {len(couples) * 2}'
                         )

        request = factory.post(reverse('api:scheduleverify_for_date', kwargs={'date': date}))
        force_authenticate(request, user=self.admin_user)
        response = ScheduleNotifyView.as_view()(request, date=date)
        self.assertEqual(response.status_code, 200)