Skip to content

Commit 25404a0

Browse files
committed
fixing broken tests
1 parent a1fcf90 commit 25404a0

File tree

7 files changed

+55
-20
lines changed

7 files changed

+55
-20
lines changed

oioioi/contests/processors.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ def recent_contests(request):
3535
for c in (mapping.get(id) for id in ids)
3636
if c is not None and c != request.contest
3737
]
38-
elif False:
39-
visible_query = visible_contests_queryset(request)
40-
c_views = (
41-
Contest.objects.filter(contestview__user=request.real_user)
42-
.filter(visible_query)
43-
.order_by('-contestview__timestamp')
44-
.only("id", "name")
45-
.distinct()
46-
)[: getattr(settings, "NUM_RECENT_CONTESTS", 5)]
47-
return list(c_views)
4838
else:
4939
c_views = ContestView.objects.filter(user=request.real_user).select_related(
5040
'contest'

oioioi/globalmessage/processors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def global_message_processor(request):
1616
if message.visible(time):
1717
return {
1818
'extra_body_global_message': render_to_string(
19-
'global-message-user.html', {'global_message': message, 'start': message.start.strftime('%s')}
19+
'global-message-user.html', {'global_message': message, 'start': message.start.strftime('%s') if message.start else ''}
2020
),
2121
'extra_admin_global_message': render_to_string(
22-
'global-message-admin.html', {'global_message': message, 'start': message.start.strftime('%s')}
22+
'global-message-admin.html', {'global_message': message, 'start': message.start.strftime('%s') if message.start else ''}
2323
),
2424
}
2525

oioioi/oi/files/rspo_schools.bak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Numer RSPO;REGON;NIP;Typ;Nazwa;Kod terytorialny województwo;Kod terytorialny powiat;Kod terytorialny gmina;Kod terytorialny miejscowość;Kod terytorialny ulica;Województwo;Powiat;Gmina;Miejscowość;Rodzaj miejscowości;Ulica;Numer budynku;Numer lokalu;Kod pocztowy;Poczta;Telefon;Faks;E-mail;Strona www;Publiczność status;Kategoria uczniów;Specyfika placówki;Imię i nazwisko dyrektora;Data założenia;Data rozpoczęcia działalności;Data likwidacji;Typ organu prowadzącego;Nazwa organu prowadzącego;REGON organu prowadzącego;NIP organu prowadzącego;Województwo organu prowadzącego;Powiat organu prowadzącego;Gmina organu prowadzącego;Miejsce w strukturze;RSPO podmiotu nadrzędnego;Typ podmiotu nadrzędnego;Nazwa podmiotu nadrzędnego;Liczba uczniów;Tereny sportowe;Języki nauczane;Czy zatrudnia logopedę;Czy zatrudnia psychologa;Czy zatrudnia pedagoga;Oddziały podstawowe wg specyfiki;Oddziały dodatkowe;Zawód;Zawód artystyczny;Zawód w KPSS;Dziedzina BCU

oioioi/oi/files/rspo_schools.csv

Lines changed: 27 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{
3+
"pk": 1,
4+
"model": "oi.schooltype",
5+
"fields": {
6+
"name": "Liceum ogólnokształcące"
7+
}
8+
}
9+
]

oioioi/oi/management/commands/import_schools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def read_rspo_csv_file(self, filename):
297297
)
298298
SCHOOL_TYPES = [type.name for type in SchoolType.objects.all()]
299299
return [
300-
school
300+
{key: school[key] for key in RSPO_CSV_COLUMNS}
301301
for school in reader
302302
if (
303303
school['Typ'] in SCHOOL_TYPES

oioioi/oi/tests.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import re
44
from datetime import datetime, timedelta, timezone # pylint: disable=E0611
5+
import pytest
56

67
from django.contrib.admin.utils import quote
78
from django.contrib.auth.models import User
@@ -25,6 +26,7 @@ class TestOIAdmin(TestCase):
2526
'test_contest',
2627
'test_oi_registration',
2728
'test_permissions',
29+
'test_school_types',
2830
]
2931

3032
def test_admin_menu(self):
@@ -39,12 +41,18 @@ def test_admin_menu(self):
3941
self.assertNotContains(response, 'Regions')
4042

4143
def test_schools_import(self):
42-
filename = os.path.join(os.path.dirname(__file__), 'files', 'schools.csv')
44+
filename = os.path.join(os.path.dirname(__file__), 'files', 'rspo_schools.csv')
45+
backup_filename = os.path.join(os.path.dirname(__file__), 'files', 'rspo_schools.bak')
4346
manager = import_schools.Command()
44-
manager.run_from_argv(['manage.py', 'import_schools', filename])
45-
self.assertEqual(School.objects.count(), 3)
46-
school = School.objects.get(postal_code='02-044')
47-
self.assertEqual(school.city, u'Bielsko-Biała Zdrój')
47+
manager.run_from_argv([
48+
'manage.py',
49+
'import_schools',
50+
'--first-import', filename,
51+
'--backup-filename', backup_filename
52+
])
53+
self.assertEqual(School.objects.count(), 26)
54+
school = School.objects.get(postal_code='02-172')
55+
self.assertEqual(school.city, 'Włochy')
4856

4957
def test_safe_exec_mode(self):
5058
contest = Contest.objects.get()
@@ -172,7 +180,6 @@ def test_participants_registration(self):
172180

173181
self.assertContains(response, 'Postal code')
174182
self.assertContains(response, 'School')
175-
self.assertContains(response, 'add it')
176183
self.assertContains(response, 'Test terms accepted')
177184
self.assertContains(response, '1977')
178185

@@ -201,15 +208,16 @@ def test_participants_registration(self):
201208
self.assertEqual(registration.address, reg_data['address'])
202209
self.assertEqual(registration.school.address, 'Nowowiejska 37a')
203210

211+
@pytest.mark.xfail
204212
def test_registration_with_new_school(self):
213+
"""currently the registration form for OI does not support adding new school"""
205214
contest = Contest.objects.get()
206215
user = User.objects.get(username='test_user')
207216
url = reverse('participants_register', kwargs={'contest_id': contest.id})
208217
self.assertTrue(self.client.login(username='test_user'))
209218
response = self.client.get(url)
210219
self.assertContains(response, 'Postal code')
211220
self.assertContains(response, 'School')
212-
self.assertContains(response, 'add it')
213221

214222
user.first_name = 'Sir Lancelot'
215223
user.last_name = 'du Lac'

0 commit comments

Comments
 (0)