Exemplo n.º 1
0
 def test_fields_autogeneration(self):
     contest = Contest()
     contest.save()
     self.assertEqual(contest.id, 'c1')
     round = Round(contest=contest)
     round.save()
     self.assertEqual(round.name, 'Round 1')
     round = Round(contest=contest)
     round.save()
     self.assertEqual(round.name, 'Round 2')
     problem = Problem()
     problem.save()
     pi = ProblemInstance(round=round, problem=problem)
     pi.save()
     self.assertEqual(pi.contest, contest)
Exemplo n.º 2
0
 def test_fields_autogeneration(self):
     contest = Contest()
     contest.save()
     self.assertEqual(contest.id, 'c1')
     round = Round(contest=contest)
     round.save()
     self.assertEqual(round.name, 'Round 1')
     round = Round(contest=contest)
     round.save()
     self.assertEqual(round.name, 'Round 2')
     problem = Problem()
     problem.save()
     pi = ProblemInstance(round=round, problem=problem)
     pi.save()
     self.assertEqual(pi.contest, contest)
Exemplo n.º 3
0
 def _add_problem(self, request, round):
     uploaded_file = request.FILES["package_file"]
     with uploaded_file_name(uploaded_file) as filename:
         backend = backend_for_package(filename)
         problem = backend.unpack(filename, original_filename=uploaded_file.name)
         if not problem.package_backend_name:
             raise AssertionError(
                 "Problem package backend (%r) did not "
                 "set Problem.package_backend_name. This is a bug in "
                 "the problem package backend." % (backend,)
             )
         if round:
             problem.contest = round.contest
             problem.save()
             pi = ProblemInstance(contest=round.contest, round=round, problem=problem)
             pi.save()
     self.message_user(request, _("Problem package uploaded."))
     return self.redirect_to_list(request, problem)
Exemplo n.º 4
0
    def test_mailsubmissions_list(self):
        c1 = Contest(id='contest1', name='Contest1', controller_name=
            'oioioi.participants.tests.ParticipantsContestController')
        c1.save()
        c2 = Contest(id='contest2', name='Contest2', controller_name=
            'oioioi.participants.tests.ParticipantsContestController')
        c2.save()
        p = Problem.objects.get()
        pi1 = ProblemInstance(contest=c1, problem=p,
            short_name='problem_instance1')
        pi1.save()
        pi2 = ProblemInstance(contest=c2, problem=p,
            short_name='problem_instance2')
        pi2.save()
        u = User.objects.get(username='******')
        f = ContentFile('aaa', name='bbbb.cpp')
        ms1 = MailSubmission(problem_instance=pi1, user=u)
        ms1.source_file.save(f.name, f)
        ms1.save()
        ms2 = MailSubmission(problem_instance=pi2, user=u)
        ms2.source_file.save(f.name, f)
        ms2.save()

        self.client.login(username='******')
        url = reverse('oioioiadmin:mailsubmit_mailsubmission_changelist',
            kwargs={'contest_id': 'contest1'})
        response = self.client.get(url)
        self.assertContains(response, 'problem_instance1')
        self.assertNotContains(response, 'problem_instance2')
        url = reverse('oioioiadmin:mailsubmit_mailsubmission_changelist',
            kwargs={'contest_id': 'contest2'})
        response = self.client.get(url)
        self.assertContains(response, 'problem_instance2')
        self.assertNotContains(response, 'problem_instance1')
Exemplo n.º 5
0
    def test_mailsubmissions_list(self):
        c1 = Contest(
            id='contest1',
            name='Contest1',
            controller_name='oioioi.participants.'
            'tests.ParticipantsContestController',
        )
        c1.save()
        c2 = Contest(
            id='contest2',
            name='Contest2',
            controller_name='oioioi.participants.'
            'tests.ParticipantsContestController',
        )
        c2.save()
        p = Problem.objects.get()
        pi1 = ProblemInstance(contest=c1,
                              problem=p,
                              short_name='problem_instance1')
        pi1.save()
        pi2 = ProblemInstance(contest=c2,
                              problem=p,
                              short_name='problem_instance2')
        pi2.save()
        u = User.objects.get(username='******')
        f = ContentFile(b'aaa', name='bbbb.cpp')
        ms1 = MailSubmission(problem_instance=pi1, user=u)
        ms1.source_file.save(f.name, f)
        ms1.save()
        ms2 = MailSubmission(problem_instance=pi2, user=u)
        ms2.source_file.save(f.name, f)
        ms2.save()

        self.assertTrue(self.client.login(username='******'))
        url = reverse(
            'oioioiadmin:mailsubmit_mailsubmission_changelist',
            kwargs={'contest_id': 'contest1'},
        )
        response = self.client.get(url)
        self.assertContains(response, 'problem_instance1')
        self.assertNotContains(response, 'problem_instance2')
        url = reverse(
            'oioioiadmin:mailsubmit_mailsubmission_changelist',
            kwargs={'contest_id': 'contest2'},
        )
        response = self.client.get(url)
        self.assertContains(response, 'problem_instance2')
        self.assertNotContains(response, 'problem_instance1')