-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add pytest unit tests #251
Merged
Merged
+621
−34
Conversation
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
pederhan
force-pushed
the
pytest-unit-tests
branch
from
June 7, 2024 13:39
4f3e500
to
9c5031e
Compare
pederhan
force-pushed
the
pytest-unit-tests
branch
from
June 12, 2024 08:51
48eaf7c
to
ec3b428
Compare
pederhan
changed the base branch from
migrate_to_pydantic
to
make-testsuite-work-again-202405
June 12, 2024 08:58
pederhan
changed the base branch from
make-testsuite-work-again-202405
to
migrate_to_pydantic
June 12, 2024 08:59
pederhan
force-pushed
the
pytest-unit-tests
branch
from
October 8, 2024 15:17
f7608eb
to
a78558a
Compare
In the app, we use these methods on the class itself, not instances of it.
terjekv
approved these changes
Oct 9, 2024
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.
Great work, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds Pytest unit tests which aim to complement the test suite by testing parts of the code that the integrations tests don't cover well (or at all).
Refactored
TokenFile
The
TokenFile
class has been refactored to make it easier to test. This includes making certain methods public, and changing some methods from class methods to instance methods.Furthermore, a
TypeAdapter
has been added to validate the contents of the token file. Following the precedent set by the existing methods, failed validation only prints an error instead of raising an exception.Inline Snapshots
In order to save time on writing tests, the
inline-snapshot
package has been used to generate snapshots of values we test against. The usage of this should be documented, but the TL;DR is:When writing a new test
One can also skip the diff view and create snapshots without previewing the changes:
NOTE: It's recommended to always use
--inline-snapshot=review
to see a diff of any modifications.Fixing failing tests
To update a test after changing something that causes it to fail: