Bumped test-coverage to ~87%

This commit is contained in:
Mawoka
2022-04-16 22:36:08 +02:00
parent 24c6b9ca2f
commit 982027eb5a
5 changed files with 53 additions and 2 deletions
+47
View File
@@ -313,3 +313,50 @@ class TestQuiz:
resp = test_client.get("/api/v1/quiz/list", cookies={"access_token": token})
assert resp.status_code == 200
assert resp.json()[0]["id"] == ValueStorage.quiz_id
@pytest.mark.asyncio
async def test_update_quiz(self, test_client):
example_quiz["public"] = True
example_quiz["questions"][1]["image"] = "https://i.imgur.com/sSNSy77.png"
resp = test_client.post(
"/api/v1/users/token/cookie", data={"username": test_user_email, "password": test_user_password}
)
token = resp.cookies["access_token"]
resp = test_client.put(f"/api/v1/quiz/update/{ValueStorage.quiz_id}", json=example_quiz,
cookies={"access_token": token})
assert resp.status_code == 200
resp = test_client.put(f"/api/v1/quiz/update/f183e091-a863-44ec-a1b7-c70eb92e3f6a", json=example_quiz,
cookies={"access_token": token})
assert resp.status_code == 404
resp = test_client.put(f"/api/v1/quiz/update/saddsaasddsadsa", json=example_quiz,
cookies={"access_token": token})
assert resp.status_code == 400
@pytest.mark.asyncio
async def test_get_public_quiz(self, test_client):
resp = test_client.post(
"/api/v1/users/token/cookie", data={"username": test_user_email, "password": test_user_password}
)
token = resp.cookies["access_token"]
resp = test_client.get(f"/api/v1/quiz/get/{ValueStorage.quiz_id}", cookies={"access_token": token})
assert resp.status_code == 200
resp = test_client.get(f"/api/v1/quiz/get/public/f183e091-a863-44ec-a1b7-c70eb92e3f6a",
cookies={"access_token": token})
assert resp.status_code == 404
resp = test_client.get(f"/api/v1/quiz/get/public/dadasdas92e3f6a",
cookies={"access_token": token})
assert resp.status_code == 400
@pytest.mark.asyncio
async def test_import_quiz(self, test_client):
resp = test_client.post(
"/api/v1/users/token/cookie", data={"username": test_user_email, "password": test_user_password}
)
token = resp.cookies["access_token"]
resp = test_client.post(f"/api/v1/quiz/import/1f95eb0b-fcf4-4db2-879b-5418ef75116b",
cookies={"access_token": token})
assert resp.status_code == 200
ValueStorage.imported_quizzes.append(resp.json()["id"])
resp = test_client.post(f"/api/v1/quiz/import/1f95eb0bdassdadasdas",
cookies={"access_token": token})
assert resp.text == '"quiz not found"'