Skip to content

Commit

Permalink
Create tests_monitoring file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Jacniacki committed May 22, 2024
1 parent beca5c8 commit 1354ab6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions oioioi/statistics/tests_monitoring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from datetime import datetime, timezone # pylint: disable=E0611

from django.contrib.auth.models import User
from django.test import RequestFactory
from django.urls import reverse

from oioioi.base.tests import TestCase, fake_time
from oioioi.contests.models import Contest, ProblemInstance


class TestContestMonitoringViews(TestCase):
fixtures = [
'test_users',
'test_contest',
'test_full_package',
'test_problem_instance',
'test_submission',
'test_submission_another_user_for_statistics',
'test_extra_rounds',
'test_extra_problem',
'test_permissions',
]

def setUp(self):
self.request = RequestFactory().request()
self.request.user = User.objects.get(username='test_user')
self.request.contest = Contest.objects.get()
self.request.timestamp = datetime.now().replace(tzinfo=timezone.utc)

def test_submission_types(self):
contest = Contest.objects.get()
url = reverse('monitoring', kwargs={'contest_id': contest.id})

# Without StatisticsConfig model
self.assertTrue(self.client.login(username='test_admin'))
with fake_time(datetime(2015, 8, 5, tzinfo=timezone.utc)):
response = self.client.get(url)

f = open("monitoring_page.html", "a")
f.write(str(response.content))
f.close()

0 comments on commit 1354ab6

Please sign in to comment.