-
Notifications
You must be signed in to change notification settings - Fork 18
Feat/add backend tests #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thank you for your contribution I'll take a close look at the changes. 🙌 |
0010aor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your contribution! 🙌
I can really see the hard work you put into this.
backend/src/flashcards/services.py
Outdated
| result = session.exec(statement).first() | ||
| if result: | ||
| return result[1], result[0] | ||
| # Not used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, I think we can completely remove it
backend/src/flashcards/services.py
Outdated
| ) -> PracticeSession: | ||
| return session.get(PracticeSession, practice_session_id) | ||
| # Not used | ||
| # def get_session_statistics( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this too.
| assert len(content["data"]) <= 3 | ||
|
|
||
|
|
||
| def test_read_cards_wtih_nonexistent_collection( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo here
| assert test_card["id"] in card_ids | ||
|
|
||
|
|
||
| def test_read_cards_with_pagnation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo here
| ): | ||
| collection_id = test_collection["id"] | ||
| card_count = 3 | ||
| # Create multiple collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can create a fixture for a collection that contain multiples cards
| normal_user_token_headers: dict[str, str], | ||
| ): | ||
| data_count = 5 | ||
| # Create multiple collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can reuse the mention fixture here too
| test_collection: dict[str, Any], | ||
| ): | ||
| data_count = 3 | ||
| # Create multiple collections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| def test_practice_session( | ||
| db: Session, test_collection: Collection, test_multiple_cards: list[Card] | ||
| ) -> PracticeSession: | ||
| session = get_or_create_practice_session( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ = test_multiple_cards
session = get_or_create_practice_session(
session=db, collection_id=test_collection.id, user_id=test_collection.user_id
)
return session
to avoid unused function argument from ruff.
|
@0010aor Thanks for the review, already update your suggestions. |
|
Hi @0010aor, Is it okay for me to open a new PR for adding backend testing in Github Action Workflow? |
That would be great! Thanks |
This PR add the flashcards / stats related tests in #56