Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 18 additions & 41 deletions backend/api/v1/v1_forms/tests/tests_form_seeder.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ def test_call_command(self):
forms = Forms.objects.all().delete()
json_forms = [
"Governance and policy",
"Health Facilities",
"Household",
"Urban Sanitation",
"CLTS",
"WASH in Schools",
"Water System",
"RTMIS Community Monitoring Form",
"RTMIS School WASH Form",
Expand Down Expand Up @@ -104,48 +100,29 @@ def test_call_command(self):
content_type='application/json',
**{'HTTP_AUTHORIZATION': f'Bearer {token}'})
self.assertEqual(200, response.status_code)
response = self.client.get("/api/v1/form/web/519630048",

# TEST USING ./source/short-test-form.test.json
response = self.client.get("/api/v1/form/web/16993539153551",
follow=True,
content_type='application/json',
**{'HTTP_AUTHORIZATION': f'Bearer {token}'})
self.assertEqual(200, response.status_code)
response = response.json()
self.assertEqual("Introduction", response["question_group"][0]["name"])
self.assertEqual(364240038,
response["question_group"][0]["question"][0]['id'])
self.assertEqual('Name of the data collector (Enumerator)',
response["question_group"][0]["question"][0]['name'])
self.assertEqual(True,
response["question_group"][0]["question"][0]['meta'])
self.assertEqual(5196300481,
response["question_group"][0]["question"][1]['id'])
self.assertEqual('Organisation',
response["question_group"][0]["question"][1]['name'])
self.assertEqual({"endpoint": "/api/v1/organisations?attributes=2"},
response["question_group"][0]["question"][1]['api'])
self.assertEqual(517690051,
response["question_group"][0]["question"][2]['id'])
self.assertEqual('Household code',
response["question_group"][0]["question"][2]['name'])
self.assertEqual(
['id', 'name', 'order'],
list(response["question_group"][0]["question"][3]['option'][0]))
self.assertEqual(False,
response["question_group"][0]["question"][3]['meta'])

response = self.client.get("/api/v1/form/519630048",
follow=True,
content_type='application/json')
self.assertEqual(200, response.status_code)
response = response.json()
introduction = self.get_question_group(response, 'Introduction')
demographics = self.get_question_group(response, 'Demographics')
self.assertEqual(
["chart", "aggregate", "table", "advanced_filter"],
demographics["question"][3]["attributes"])
self.assertEqual('Enumerator', introduction["question"][0]['name'])
self.assertEqual('Name of the data collector (Enumerator)',
introduction["question"][0]['text'])
administration_found = False
for qg in response["question_group"]:
for q in qg["question"]:
if q["id"] == 16993548493821:
self.assertEqual("cascade", q["type"])
self.assertEqual(
{
"endpoint": "/api/v1/administration",
"initial": 1,
"list": "children"
},
q["api"],
)
administration_found = True
self.assertTrue(administration_found)

def test_additional_attributes(self):
seed_administration_test()
Expand Down