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

Not so quick fix to allow "/" at end of validator URL, plus fixes and tests for --as_type #267

Merged
merged 5 commits into from
May 6, 2020

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented May 6, 2020

Handles an edge case that got lost in the last PR, i.e. handling slashes at the end of the URL provided at the CLI.

@ml-evs ml-evs requested a review from CasperWA May 6, 2020 14:47
@ml-evs
Copy link
Member Author

ml-evs commented May 6, 2020

Annoyingly missed this from the last PR... sorry @CasperWA!

@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #267 into master will increase coverage by 0.77%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #267      +/-   ##
==========================================
+ Coverage   89.15%   89.92%   +0.77%     
==========================================
  Files          54       54              
  Lines        2241     2244       +3     
==========================================
+ Hits         1998     2018      +20     
+ Misses        243      226      -17     
Flag Coverage Δ
#unittests 89.92% <83.33%> (+0.77%) ⬆️
Impacted Files Coverage Δ
optimade/validator/validator.py 74.03% <83.33%> (+5.94%) ⬆️
optimade/server/routers/utils.py 97.70% <0.00%> (+0.76%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b5cc923...67b7dd5. Read the comment docs.

Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

I guess I wasn't thorough enough... I'll be even MORE nitpicky now then ! 😆

No but seriously, while is nicer ... 😅

optimade/validator/validator.py Outdated Show resolved Hide resolved
…nt :P

Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
@ml-evs
Copy link
Member Author

ml-evs commented May 6, 2020

No but seriously, while is nicer ... sweat_smile

👍 We can just squash away my sarcastic commit message :P

@CasperWA
Copy link
Member

CasperWA commented May 6, 2020

Oh no! What about id's with / in them, or rather, ending with /?

@ml-evs
Copy link
Member Author

ml-evs commented May 6, 2020

Oh no! What about id's with / in them, or rather, ending with /?

I don't think we allow this at the moment right? You can only validate endpoints with multi-entry response types, not individual entries with the entry type

@CasperWA
Copy link
Member

CasperWA commented May 6, 2020

Oh no! What about id's with / in them, or rather, ending with /?

I don't think we allow this at the moment right? You can only validate endpoints with multi-entry response types, not individual entries with the entry type

That's okay then.

@ml-evs
Copy link
Member Author

ml-evs commented May 6, 2020

Oh no! What about id's with / in them, or rather, ending with /?

I don't think we allow this at the moment right? You can only validate endpoints with multi-entry response types, not individual entries with the entry type

That's okay then.

It looks like this has messed something else up though, don't merge this yet...

@ml-evs
Copy link
Member Author

ml-evs commented May 6, 2020

The --as_type functionality is so brittle as currently implemented, but I've patched it back together for now. It's unfortunately hard to add tests for it too, as we there are slightly different code paths when querying a remote vs providing a client (as the tests do). I've managed to mock the underlying Client class from the validator so we get more realistic testing. I think it would be sensible to do this in the other tests, so we can eventually deprecate the ability to pass the validator a Client-like object anyway (which is where a lot of these bugs have come from).

@ml-evs ml-evs force-pushed the ml-evs/validate_pagination branch from 6bbfd50 to ce36eb0 Compare May 6, 2020 15:56
@CasperWA
Copy link
Member

CasperWA commented May 6, 2020

The --as_type functionality is so brittle as currently implemented, but I've patched it back together for now. It's unfortunately hard to add tests for it too, as we there are slightly different code paths when querying a remote vs providing a client (as the tests do). I've managed to mock the underlying Client class from the validator so we get more realistic testing. I think it would be sensible to do this in the other tests, so we can eventually deprecate the ability to pass the validator a Client-like object anyway (which is where a lot of these bugs have come from).

Seems reasonable.
We might need to reconsider what parameters the validator CLI should have as well and whether --as-type is relevant. Although it may be, since one could have a special endpoint that still serves "valid" structures.

@ml-evs
Copy link
Member Author

ml-evs commented May 6, 2020

Also turns out we definitely do allow single entry response validation, I am talking so much rubbish today...

@ml-evs
Copy link
Member Author

ml-evs commented May 6, 2020

The --as_type functionality is so brittle as currently implemented, but I've patched it back together for now. It's unfortunately hard to add tests for it too, as we there are slightly different code paths when querying a remote vs providing a client (as the tests do). I've managed to mock the underlying Client class from the validator so we get more realistic testing. I think it would be sensible to do this in the other tests, so we can eventually deprecate the ability to pass the validator a Client-like object anyway (which is where a lot of these bugs have come from).

Seems reasonable.
We might need to reconsider what parameters the validator CLI should have as well and whether --as-type is relevant. Although it may be, since one could have a special endpoint that still serves "valid" structures.

Yeah the whole reason for this initially was to validate nomad with their calculations<->structures renaming

@CasperWA
Copy link
Member

CasperWA commented May 6, 2020

Also turns out we definitely do allow single entry response validation, I am talking so much rubbish today...

Hehe. You need to go get a beer and a sleep 😄

@ml-evs ml-evs changed the title Quick fix to allow / at end of validator URL Not so quick fix to allow "/" at end of validator URL, plus fixes and tests for --as_type May 6, 2020
@ml-evs ml-evs requested a review from CasperWA May 6, 2020 16:14
Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Look's good!
A couple of questions/comments :)

tests/server/test_server_validation.py Outdated Show resolved Hide resolved
tests/server/test_server_validation.py Show resolved Hide resolved
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
@ml-evs ml-evs requested a review from CasperWA May 6, 2020 16:34
Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Thanks for not so quick quick-fix @ml-evs ! 😄

@ml-evs ml-evs merged commit f41dac7 into master May 6, 2020
@CasperWA CasperWA deleted the ml-evs/validate_pagination branch June 2, 2020 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants