petitcours.tests -- Add PCAbility, PCDemande and PCSubject factories
This commit is contained in:
parent
8be913cbf9
commit
25dfe2f496
1 changed files with 27 additions and 0 deletions
|
@ -1,5 +1,12 @@
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
from gestioncof.petits_cours_models import (
|
||||||
|
PetitCoursAbility,
|
||||||
|
PetitCoursAttributionCounter,
|
||||||
|
PetitCoursDemande,
|
||||||
|
PetitCoursSubject,
|
||||||
|
)
|
||||||
|
|
||||||
User = get_user_model()
|
User = get_user_model()
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,3 +73,23 @@ def create_root(username, attrs=None):
|
||||||
attrs.setdefault("is_staff", True)
|
attrs.setdefault("is_staff", True)
|
||||||
attrs.setdefault("is_superuser", True)
|
attrs.setdefault("is_superuser", True)
|
||||||
return _create_user(username, attrs=attrs)
|
return _create_user(username, attrs=attrs)
|
||||||
|
|
||||||
|
|
||||||
|
def create_petitcours_ability(**kwargs):
|
||||||
|
if "user" not in kwargs:
|
||||||
|
kwargs["user"] = create_user()
|
||||||
|
if "matiere" not in kwargs:
|
||||||
|
kwargs["matiere"] = create_petitcours_subject()
|
||||||
|
if "niveau" not in kwargs:
|
||||||
|
kwargs["niveau"] = "college"
|
||||||
|
ability = PetitCoursAbility.objects.create(**kwargs)
|
||||||
|
PetitCoursAttributionCounter.get_uptodate(ability.user, ability.matiere)
|
||||||
|
return ability
|
||||||
|
|
||||||
|
|
||||||
|
def create_petitcours_demande(**kwargs):
|
||||||
|
return PetitCoursDemande.objects.create(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def create_petitcours_subject(**kwargs):
|
||||||
|
return PetitCoursSubject.objects.create(**kwargs)
|
||||||
|
|
Loading…
Reference in a new issue