testutils: organizator nema usera + komentar k res_vyber (drive res_sel)
This commit is contained in:
parent
4b0eb89e00
commit
21572fa2ac
1 changed files with 7 additions and 5 deletions
|
@ -88,7 +88,7 @@ def gen_resitele(rnd, osoby, skoly):
|
|||
for os in osoby:
|
||||
rand = rnd.randint(0, 8)
|
||||
if not (rand % 8 == 0):
|
||||
resitele.append(Resitel.objects.create(osoba=os, skola=rnd.choice([skoly]),
|
||||
resitele.append(Resitel.objects.create(osoba=os, skola=rnd.choice(skoly),
|
||||
rok_maturity=rnd.randint(2019, 2029),
|
||||
zasilat=rnd.choice(Resitel.ZASILAT_CHOICES)))
|
||||
return resitele
|
||||
|
@ -100,7 +100,7 @@ def gen_prijemci(rnd, osoby, kolik=10):
|
|||
prijemci.append(Prijemce.objects.create(osoba=rand_os))
|
||||
return prijemci
|
||||
|
||||
def gen_organizatori(rnd, osoby, last_rocnik):
|
||||
def gen_organizatori(rnd, osoby, last_rocnik, users):
|
||||
organizatori = []
|
||||
for os in osoby:
|
||||
rand = rnd.randint(0, 8)
|
||||
|
@ -114,7 +114,7 @@ def gen_organizatori(rnd, osoby, last_rocnik):
|
|||
organizatori.append(Organizator.objects.create(osoba=os,
|
||||
user=rnd.choice(users),
|
||||
organizuje_od=od, organizuje_do=do))
|
||||
return organizatri
|
||||
return organizatori
|
||||
|
||||
def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size):
|
||||
'''cislo = cislo cisla v rocniku, nikoli objekt Cislo '''
|
||||
|
@ -161,6 +161,8 @@ def gen_ulohy_do_cisla(rnd, cislo, organizatori, resitele, slovnik_cisel, size):
|
|||
# reseni ulohy
|
||||
poc_reseni = rnd.randint(size // 2, size * 2)
|
||||
poc_resitel = rnd.randint(1, 3)
|
||||
# vybereme nahodny vzorek resitelu o delce poctu reseni
|
||||
# (nebo skoro vsechny resitele, pokud jich je mene nez pocet reseni)
|
||||
res_sel = rnd.sample(resitele, min(poc_reseni, len(resitele) - 2))
|
||||
for resitel in res_sel:
|
||||
res = Reseni.objects.create(problem = p,
|
||||
|
@ -192,7 +194,7 @@ def create_test_data(size = 6, rnd = None):
|
|||
usernames = ['anet', 'bara', 'cyril', 'david', 'eva', 'filip']
|
||||
users = []
|
||||
for usr in usernames[:size]:
|
||||
u = User.objects.create_user(username=usr, password=usr)
|
||||
u = User.objects.create(username=usr, password=usr)
|
||||
u.first_name = usr.capitalize()
|
||||
u.save()
|
||||
users.append(u)
|
||||
|
@ -207,7 +209,7 @@ def create_test_data(size = 6, rnd = None):
|
|||
# resitele a organizatori
|
||||
last_rocnik = 25
|
||||
resitele = gen_resitele(rnd, osoby, skoly)
|
||||
organizatori = gen_organizatori(rnd, osoby, last_rocnik)
|
||||
organizatori = gen_organizatori(rnd, osoby, last_rocnik, users)
|
||||
|
||||
# prijemci
|
||||
prijemci = gen_prijemci(rnd)
|
||||
|
|
Loading…
Reference in a new issue