format files with black

This commit is contained in:
Aarni Halinen
2022-01-13 22:10:24 +02:00
parent a0f062c697
commit 11efcdd579
178 changed files with 3763 additions and 2324 deletions
+28 -22
View File
@@ -13,31 +13,35 @@ class TemplateQuestionCase(APITestCase):
def setUp(self):
self.questions = [
TemplateQuestion.objects.create(
name="Testi1",
questions=ALL_QUESTION_TYPES
name="Testi1", questions=ALL_QUESTION_TYPES
),
TemplateQuestion.objects.create(
name="Testi2",
questions=ALL_QUESTION_TYPES
)
name="Testi2", questions=ALL_QUESTION_TYPES
),
]
username, password = "test_admin", "password123"
self.authClient = User.objects.create_superuser(username, "myemail@test.com", password)
self.authClient = User.objects.create_superuser(
username, "myemail@test.com", password
)
def test_get(self):
response = self.client.get("/api/questions/", format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data["results"], SavedQuestionsSerializer(self.questions, many=True).data)
response = self.client.get(f"/api/questions/{self.questions[0].id}/", format="json")
self.assertEqual(
response.data["results"],
SavedQuestionsSerializer(self.questions, many=True).data,
)
response = self.client.get(
f"/api/questions/{self.questions[0].id}/", format="json"
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data, SavedQuestionsSerializer(self.questions[0]).data)
self.assertEqual(
response.data, SavedQuestionsSerializer(self.questions[0]).data
)
def test_post(self):
new = {
"name": "testi3",
"questions": json.dumps(ALL_QUESTION_TYPES)
}
new = {"name": "testi3", "questions": json.dumps(ALL_QUESTION_TYPES)}
response = self.client.post("/api/questions/", new, format="json")
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertEqual(TemplateQuestion.objects.count(), 2)
@@ -49,23 +53,23 @@ class TemplateQuestionCase(APITestCase):
self.assertEqual(TemplateQuestion.objects.count(), 3)
def test_update(self):
new = {
"name": "uusi testi2",
"questions": json.dumps({})
}
response = self.client.put(f"/api/questions/{self.questions[0].id}/", new, format="json")
new = {"name": "uusi testi2", "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)
self.assertEqual(TemplateQuestion.objects.count(), 2)
# Authenticate
self.client.force_authenticate(user=self.authClient)
response = self.client.put(f"/api/questions/{self.questions[0].id}/", new, format="json")
response = self.client.put(
f"/api/questions/{self.questions[0].id}/", new, format="json"
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(TemplateQuestion.objects.count(), 2)
self.assertEqual(
TemplateQuestion.objects.get(id=self.questions[0].id).name,
"uusi testi2"
TemplateQuestion.objects.get(id=self.questions[0].id).name, "uusi testi2"
)
def test_delete(self):
@@ -76,6 +80,8 @@ class TemplateQuestionCase(APITestCase):
# Authenticate
self.client.force_authenticate(user=self.authClient)
response = self.client.delete(f"/api/questions/{self.questions[0].id}/", format="json")
response = self.client.delete(
f"/api/questions/{self.questions[0].id}/", format="json"
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(TemplateQuestion.objects.get(id=id).deleted, True)