Files
web2.0-backend/webapp/tests/signup_fixture.py
T
2019-11-11 00:18:48 +02:00

38 lines
1.1 KiB
Python

from webapp.models import Signup, SignupForm
from django.utils import timezone
from webapp.utils import month_from_now
import json
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"]}
]
ALL_QUESTION_TYPES_ANSWER = {"j5CeRZDvl": "Testi", "RHJhSoaLD": "maybe", "i10d426d5": ["B"]}
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": json.dumps(answer)
}