finish template question API
This commit is contained in:
@@ -14,11 +14,11 @@ class TemplateQuestionCase(APITestCase):
|
||||
self.questions = [
|
||||
TemplateQuestion.objects.create(
|
||||
name="Testi1",
|
||||
question=ALL_QUESTION_TYPES
|
||||
questions=ALL_QUESTION_TYPES
|
||||
),
|
||||
TemplateQuestion.objects.create(
|
||||
name="Testi2",
|
||||
question=ALL_QUESTION_TYPES
|
||||
questions=ALL_QUESTION_TYPES
|
||||
)
|
||||
]
|
||||
|
||||
@@ -36,7 +36,7 @@ class TemplateQuestionCase(APITestCase):
|
||||
def test_post(self):
|
||||
new = {
|
||||
"name": "testi3",
|
||||
"question": json.dumps(ALL_QUESTION_TYPES)
|
||||
"questions": json.dumps(ALL_QUESTION_TYPES)
|
||||
}
|
||||
response = self.client.post("/api/questions/", new, format="json")
|
||||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
|
||||
@@ -51,7 +51,7 @@ class TemplateQuestionCase(APITestCase):
|
||||
def test_update(self):
|
||||
new = {
|
||||
"name": "uusi testi2",
|
||||
"question": json.dumps({})
|
||||
"questions": json.dumps({})
|
||||
}
|
||||
response = self.client.put(f"/api/questions/{self.questions[0].id}/", new, format="json")
|
||||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
|
||||
@@ -69,12 +69,13 @@ class TemplateQuestionCase(APITestCase):
|
||||
)
|
||||
|
||||
def test_delete(self):
|
||||
response = self.client.delete(f"/api/questions/{self.questions[0].id}/", format="json")
|
||||
id = self.questions[0].id
|
||||
response = self.client.delete(f"/api/questions/{id}/", format="json")
|
||||
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
|
||||
self.assertEqual(TemplateQuestion.objects.count(), 2)
|
||||
|
||||
# Authenticate
|
||||
self.client.force_authenticate(user=self.authClient)
|
||||
response = self.client.delete(f"/api/questions/{self.questions[0].id}/", format="json")
|
||||
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
|
||||
self.assertEqual(TemplateQuestion.objects.count(), 1)
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(TemplateQuestion.objects.get(id=id).deleted, True)
|
||||
|
||||
Reference in New Issue
Block a user