Skip to content
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 compatibility for httpx-based TestClient for latest FastAPI version #1460

Merged
merged 5 commits into from Jan 5, 2023

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Jan 3, 2023

This PR updates tests, validator and client usage of requests/httpx to add compatibility for the new httpx-based TestClient required by the latest FastAPI version (whilst also maintaining compatibility with older versions).

To do this, I had to:

  • drop pytest-httpx as it caused infinite recursion between the mocked test client and the mocked requests themselves, with no clean workaround
  • some fixes to get string URLs back from the internal httpx.URL now used within the test client
  • added ability to specify a custom HTTP client to the OptimadeClient, so a patched test client can be specified directly
  • some tweaks associated with differences of truthiness of non-200 responses between httpx and requests

We can probably now begin the process of using httpx in the validator too, though a naive switch out lead to some errors that I don't want to fix in this PR.

@ml-evs ml-evs added validator Related to the OPTIMADE validator tests Related to tests client Issues/PRs relating to the OPTIMADE client. labels Jan 3, 2023
@codecov
Copy link

codecov bot commented Jan 3, 2023

Codecov Report

Merging #1460 (c244123) into master (9744e6c) will decrease coverage by 0.02%.
The diff coverage is 82.35%.

@@            Coverage Diff             @@
##           master    #1460      +/-   ##
==========================================
- Coverage   91.45%   91.43%   -0.03%     
==========================================
  Files          74       74              
  Lines        4399     4411      +12     
==========================================
+ Hits         4023     4033      +10     
- Misses        376      378       +2     
Flag Coverage Δ
project 91.43% <82.35%> (-0.03%) ⬇️
validator 90.77% <58.82%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
optimade/client/cli.py 88.46% <ø> (ø)
optimade/validator/validator.py 83.48% <75.00%> (+0.02%) ⬆️
optimade/client/client.py 80.75% <84.61%> (+0.04%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

dependabot bot and others added 5 commits January 4, 2023 12:20
Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.86.0 to 0.88.0.
- [Release notes](https://github.com/tiangolo/fastapi/releases)
- [Commits](tiangolo/fastapi@0.86.0...0.88.0)

---
updated-dependencies:
- dependency-name: fastapi
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Copy link
Contributor

@JPBergsma JPBergsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ml-evs
Copy link
Member Author

ml-evs commented Jan 5, 2023

Thanks for the review @JPBergsma!

@ml-evs ml-evs merged commit eb8f1fa into master Jan 5, 2023
@ml-evs ml-evs deleted the ml-evs/update_testclient branch January 5, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Issues/PRs relating to the OPTIMADE client. tests Related to tests validator Related to the OPTIMADE validator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants