-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
49 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
from datetime import datetime | ||
|
||
from fastapi import status | ||
from fastapi.testclient import TestClient | ||
from sqlmodel import Session | ||
|
||
from tests.utils.quiz import create_random_quiz | ||
from tests.utils.quiz import create_random_daily_quiz | ||
|
||
|
||
def test_get_daily_quizzes(client: TestClient, session: Session): | ||
saved_quizzes = [create_random_quiz(session) for _ in range(5)] | ||
today = datetime.utcnow().date() | ||
saved_daily_quizzes = [create_random_daily_quiz(session, target_date=today) for _ in range(5)] | ||
|
||
res = client.get("/quiz/daily_quizes") | ||
assert res.status_code == status.HTTP_200_OK | ||
|
||
res_json = res.json() | ||
assert len(res_json["daily_quizes"]) == 5 | ||
for daily_quiz_json, saved_quiz in zip(res_json["daily_quizes"], saved_quizzes): | ||
for daily_quiz_json, saved_daily_quiz in zip(res_json["daily_quizes"], saved_daily_quizzes): | ||
assert len(daily_quiz_json["screenshots"]) == 5 | ||
assert daily_quiz_json["screenshots"] == [s.url for s in saved_quiz.screenshots] | ||
assert daily_quiz_json["quiz_id"] == saved_quiz.id | ||
assert daily_quiz_json["screenshots"] == [s.url for s in saved_daily_quiz.quiz.screenshots] | ||
assert daily_quiz_json["quiz_id"] == saved_daily_quiz.quiz_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters