def test_round_extension(self): contest = Contest.objects.get() round1 = Round.objects.get(pk=1) round2 = Round.objects.get(pk=2) problem_instance1 = ProblemInstance.objects.get(pk=1) problem_instance2 = ProblemInstance.objects.get(pk=2) self.assertTrue(problem_instance1.round == round1) self.assertTrue(problem_instance2.round == round2) round1.start_date = datetime(2012, 7, 31, tzinfo=utc) round1.end_date = datetime(2012, 8, 5, tzinfo=utc) round1.save() round2.start_date = datetime(2012, 8, 10, tzinfo=utc) round2.end_date = datetime(2012, 8, 12, tzinfo=utc) round2.save() user = User.objects.get(username='******') ext = RoundTimeExtension(user=user, round=round1, extra_time=10) ext.save() with fake_time(datetime(2012, 8, 5, 0, 5, tzinfo=utc)): self.client.login(username='******') response = self.submit_file(contest, problem_instance1) self.assertEqual(200, response.status_code) self.assertIn('Sorry, there are no problems', response.content) self.client.login(username='******') response = self.submit_file(contest, problem_instance1) self._assertSubmitted(contest, response) with fake_time(datetime(2012, 8, 5, 0, 11, tzinfo=utc)): response = self.submit_file(contest, problem_instance1) self.assertEqual(200, response.status_code) self.assertIn('Sorry, there are no problems', response.content) with fake_time(datetime(2012, 8, 12, 0, 5, tzinfo=utc)): response = self.submit_file(contest, problem_instance2) self.assertEqual(200, response.status_code) self.assertIn('Sorry, there are no problems', response.content)
def test_submissions_visibility(self): contest = Contest.objects.get() url = reverse('my_submissions', kwargs={'contest_id': contest.id}) self.client.login(username='******') with fake_time(datetime(2012, 8, 5, tzinfo=utc)): response = self.client.get(url) self.assertAllIn(['zad1', 'zad3', 'zad4'], response.content) self.assertNoneIn([ 'zad2', ], response.content) self.assertIn('contests/my_submissions.html', [t.name for t in response.templates]) self.assertEqual(response.content.count('<td>34</td>'), 2) with fake_time(datetime(2015, 8, 5, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 4) with fake_time(datetime(2012, 7, 31, 21, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) with fake_time(datetime(2012, 7, 31, 22, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 2) round4 = Round.objects.get(pk=4) user = User.objects.get(username='******') ext = RoundTimeExtension(user=user, round=round4, extra_time=60) ext.save() with fake_time(datetime(2012, 7, 31, 22, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) round4.end_date = datetime(2012, 8, 10, 0, 0, tzinfo=utc) round4.results_date = datetime(2012, 8, 10, 0, 10, tzinfo=utc) round4.save() ext.extra_time = 0 ext.save() with fake_time(datetime(2012, 8, 10, 0, 5, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) ext.extra_time = 20 ext.save() with fake_time(datetime(2012, 8, 10, 0, 15, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) with fake_time(datetime(2012, 8, 10, 0, 21, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 2)
def test_submissions_visibility(self): contest = Contest.objects.get() url = reverse('my_submissions', kwargs={'contest_id': contest.id}) self.client.login(username='******') with fake_time(datetime(2012, 8, 5, tzinfo=utc)): response = self.client.get(url) self.assertAllIn(['zad1', 'zad3', 'zad4'], response.content) self.assertNoneIn(['zad2', ], response.content) self.assertIn('contests/my_submissions.html', [t.name for t in response.templates]) self.assertEqual(response.content.count('<td>34</td>'), 2) with fake_time(datetime(2015, 8, 5, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 4) with fake_time(datetime(2012, 7, 31, 21, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) with fake_time(datetime(2012, 7, 31, 22, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 2) round4 = Round.objects.get(pk=4) user = User.objects.get(username='******') ext = RoundTimeExtension(user=user, round=round4, extra_time=60) ext.save() with fake_time(datetime(2012, 7, 31, 22, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) round4.end_date = datetime(2012, 8, 10, 0, 0, tzinfo=utc) round4.results_date = datetime(2012, 8, 10, 0, 10, tzinfo=utc) round4.save() ext.extra_time = 0 ext.save() with fake_time(datetime(2012, 8, 10, 0, 5, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) ext.extra_time = 20 ext.save() with fake_time(datetime(2012, 8, 10, 0, 15, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 1) with fake_time(datetime(2012, 8, 10, 0, 21, tzinfo=utc)): response = self.client.get(url) self.assertEqual(response.content.count('<td>34</td>'), 2)