Cleanup po upravach routingu a testu
This commit is contained in:
parent
5d24b33d65
commit
3ac2b34dd8
2 changed files with 33 additions and 6 deletions
|
@ -5,10 +5,10 @@ import random
|
||||||
import django.contrib.auth
|
import django.contrib.auth
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from django.test import Client
|
from django.test import Client
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse, resolve
|
||||||
from django.core.management import call_command
|
from django.core.management import call_command
|
||||||
|
|
||||||
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni
|
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Soustredeni, Nastaveni
|
||||||
from seminar.testutils import create_test_data
|
from seminar.testutils import create_test_data
|
||||||
|
|
||||||
class SeminarBasicTests(TestCase):
|
class SeminarBasicTests(TestCase):
|
||||||
|
@ -26,8 +26,8 @@ class SeminarBasicTests(TestCase):
|
||||||
|
|
||||||
def test_render_cislo_e2e(self):
|
def test_render_cislo_e2e(self):
|
||||||
cs = Cislo.objects.all()
|
cs = Cislo.objects.all()
|
||||||
for c in cs[:8]:
|
for c in cs[:4]:
|
||||||
url = reverse('seminar.cislo', args=(c.id,))
|
url = reverse('seminar_cislo', args=(c.id,))
|
||||||
r = self.client.get(url)
|
r = self.client.get(url)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.content) >= 100
|
assert len(r.content) >= 100
|
||||||
|
@ -35,11 +35,26 @@ class SeminarBasicTests(TestCase):
|
||||||
|
|
||||||
def test_render_problem_e2e(self):
|
def test_render_problem_e2e(self):
|
||||||
ps = Problem.objects.all()
|
ps = Problem.objects.all()
|
||||||
for p in ps[:10]:
|
for p in ps[:4]:
|
||||||
url = reverse('seminar.problem', args=(p.id,))
|
url = reverse('seminar_problem', args=(p.id,))
|
||||||
r = self.client.get(url)
|
r = self.client.get(url)
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert len(r.content) >= 100
|
assert len(r.content) >= 100
|
||||||
# TODO: Validate cntent as HTML
|
# TODO: Validate cntent as HTML
|
||||||
|
|
||||||
|
def test_admin_url(self):
|
||||||
|
for m in [Skola, Resitel, Rocnik, Cislo, Problem, Reseni, Nastaveni]:
|
||||||
|
o = m.objects.first()
|
||||||
|
url = o.admin_url()
|
||||||
|
assert url
|
||||||
|
view = resolve(url)
|
||||||
|
assert view
|
||||||
|
|
||||||
|
def test_verejne_url(self):
|
||||||
|
for m in [Rocnik, Cislo, Problem]:
|
||||||
|
p = Problem.objects.first()
|
||||||
|
url = p.verejne_url()
|
||||||
|
assert url
|
||||||
|
view = resolve(url)
|
||||||
|
assert view
|
||||||
|
|
||||||
|
|
12
seminar/utils.py
Normal file
12
seminar/utils.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
def roman(num):
|
||||||
|
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
|
||||||
|
nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I')
|
||||||
|
res = ""
|
||||||
|
for i, n in zip(ints, nums):
|
||||||
|
res += n * (num // i)
|
||||||
|
num %= i
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue