forked from DGNum/gestioCOF
bda.tests -- Add Spectacle factories
This commit is contained in:
parent
f8610d4ff1
commit
1664554083
1 changed files with 19 additions and 0 deletions
|
@ -1,4 +1,9 @@
|
|||
from datetime import timedelta
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils import timezone
|
||||
|
||||
from ..models import CategorieSpectacle, Salle, Spectacle, Tirage
|
||||
|
||||
|
||||
def create_user(username, is_cof=False, is_buro=False):
|
||||
|
@ -15,3 +20,17 @@ def user_is_cof(user):
|
|||
|
||||
def user_is_staff(user):
|
||||
return (user is not None) and user.profile.is_buro
|
||||
|
||||
|
||||
def create_spectacle(**kwargs):
|
||||
defaults = {
|
||||
"title": "Title",
|
||||
"category": CategorieSpectacle.objects.first(),
|
||||
"date": (timezone.now() + timedelta(days=7)).date(),
|
||||
"location": Salle.objects.first(),
|
||||
"price": 10.0,
|
||||
"slots": 20,
|
||||
"tirage": Tirage.objects.first(),
|
||||
"listing": False,
|
||||
}
|
||||
return Spectacle.objects.create(**dict(defaults, **kwargs))
|
||||
|
|
Loading…
Reference in a new issue