Files
web2.0-backend/webapp/tests/signup_fixture.py
T
2019-11-10 21:38:07 +02:00

32 lines
952 B
Python

from webapp.models import Signup, SignupForm
from django.utils import timezone
from webapp.utils import month_from_now
ALL_QUESTION_TYPES = [
{"id": "j5CeRZDvl", "name": "Asd", "type": "text", "options": []}, {"id": "RHJhSoaLD", "name": "Asd2", "type": "radiobutton", "options": ["Yes", "no", "maybe"]}, {"id": "i10d426d5", "name": "Asd3", "type": "checkbox", "options": ["A", "B", "C"]}
]
def createSignupForm(name="Form1", start_time=timezone.now(), end_time=month_from_now(), questions=ALL_QUESTION_TYPES, visible=True):
return SignupForm.objects.create(
title=name,
start_time=start_time,
end_time=end_time,
questions=questions,
visible=visible
)
def createSignupObject(form, answer):
return Signup.objects.create(
signupForm=form,
answer=answer
)
def createSignupJSON(form_id, answer):
return {
"signupForm_id": form_id,
"answer": answer
}