Browse Source

Soustredeni a ucasti v testdatech

remotes/origin/vysl
Tomas Gavenciak 10 years ago
parent
commit
8241a25337
  1. 13
      seminar/tests.py
  2. 10
      seminar/testutils.py

13
seminar/tests.py

@ -44,6 +44,19 @@ class SeminarBasicTests(TestCase):
assert len(r.content) >= 100
# TODO: Validate cntent as HTML
def test_export_e2e(self):
i_url = '/aesop-export/index.csv'
i_r = self.client.get(i_url)
assert i_r.status_code == 200
ls = i_r.content.strip().split('\n')
for u in [ls[0], ls[-1]]:
ex_r = self.client.get('/aesop-export/' + u)
assert ex_r.status_code == 200
assert len(ex_r.content) >= 100
o = ovvpfile.parse(ex_r.content)
assert o.headers['version'] == '1'
def test_admin_url(self):
for m in [Skola, Resitel, Rocnik, Cislo, Problem, Reseni, Nastaveni]:
o = m.objects.first()

10
seminar/testutils.py

@ -5,7 +5,7 @@ import random
import django.contrib.auth
from django.db import transaction
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
@ -70,7 +70,7 @@ def create_test_data(size = 6, rnd = None):
for ci in range(1, cisel + 1):
vydano = datetime.date(r.prvni_rok, ci + 6, 1)
deadline = datetime.date(r.prvni_rok, ci + 8, 1) if ci + 2 < cisel else None
c = Cislo.objects.create(rocnik = r, cislo = str(ci), datum_vydani=vydano, datum_deadline=deadline)
c = Cislo.objects.create(rocnik = r, cislo = str(ci), datum_vydani=vydano, datum_deadline=deadline, verejne_db=True)
cs[ci] = c
# problemy resene v ci
@ -91,6 +91,12 @@ def create_test_data(size = 6, rnd = None):
res = Reseni.objects.create(problem = p, resitel = resitel,
body = rnd.randint(0, p.body), cislo_body = cs[ci])
sous = Soustredeni.objects.create(rocnik=Rocnik.objects.first(), verejne_db=True, misto=u'Někde',
datum_zacatku=datetime.date(2000, 11, 23), datum_konce=datetime.date(2000, 11, 27))
for res in rnd.sample(resitele, 6):
Soustredeni_Ucastnici.objects.create(resitel=res, soustredeni=sous)
sous.save()
nastaveni = Nastaveni.objects.create(aktualni_rocnik = Rocnik.objects.last(),
aktualni_cislo = Cislo.objects.all()[1])

Loading…
Cancel
Save