-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mateusz Jacniacki
committed
May 22, 2024
1 parent
beca5c8
commit 1354ab6
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|