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
Use pytest instead of unittest #390
Conversation
Codecov Report
@@ Coverage Diff @@
## master #390 +/- ##
==========================================
+ Coverage 89.62% 90.36% +0.73%
==========================================
Files 55 55
Lines 2459 2459
==========================================
+ Hits 2204 2222 +18
+ Misses 255 237 -18
Continue to review full report at Codecov.
|
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.
Looks great @CasperWA, just a couple of minor things that don't stop me accepting
Update handling of the `sort` parameter, casting the requested fields to the known aliased version.
Co-authored-by: Matthew Evans <7916000+ml-evs@users.noreply.github.com>
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.
Minor stuff, looks like the checks aren't running atm anyway... happy to accept shortly
Co-authored-by: Matthew Evans <7916000+ml-evs@users.noreply.github.com>
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 as always, cheers @CasperWA
I needed to try and push something else, in order to try and get the pre-commit test running correctly. |
Hmm. I'm not touching any files in this PR that would influence the OpenAPI generation. So I am very confused by the sudden failure of the OpenAPI diff check in pre-commit CI. Also, I cannot reproduce the error locally. |
I can reproduce it in a fresh Python 3.8 env, but can't in the 3.7 env I use for development. Will see if there's a diff between the packages getting installed. |
It's the upgrade to pydantic 1.6.1 that's causing the diff, now to figure out why pre-commit is using that version... |
Here's the change that's causing it too, from https://github.com/samuelcolvin/pydantic/blob/master/HISTORY.md
|
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.
👍
This change is actually really good. It cleans up the OpenAPI schema 👍 |
Yeah it looks good, we should remember to upgrade pydantic before we next merge back into the spec repo (if that is before dependabot triggers). |
Closes #270
This PR moves the tests completely over to the
pytest
way of doing things, instead ofunittest
.There is only a single place left that still uses
unittest
, specifically theunittest.mock.patch
feature.This may be converted to
pytest
'smonkeypatch
as well, but for now I didn't see the reason.The conversion makes much of the testing redundancy superfluous, due to the usage of the
pytest
fixtures and parametrizations.There is potentially still room for further simplifications, when testing the entry endpoints, however then the file structure and concept division may fail (if, e.g., similar tests for
/references
and/structures
are combined using parametrization, it may be more obfuscating than actuallly helpful and clear).The
client_factory()
is technically not necessary. However, since I found it useful inaiida-optimade
for a middleware test that redirects the documentation URLs between the versioned URLs, I have left it in here, if similar tests involving the versioned base URLs become relevant.