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

[#2069] Upgrade KvK Zoeken API to v2 #1016

Merged
merged 4 commits into from
Feb 20, 2024
Merged

[#2069] Upgrade KvK Zoeken API to v2 #1016

merged 4 commits into from
Feb 20, 2024

Conversation

pi-sigma
Copy link
Contributor

@pi-sigma pi-sigma commented Feb 9, 2024

Taiga: #2069

  • Add validation to API config to ensure that the API root does not contain the version number and/or endpoint
  • Add tests to ensure that API urls are constructed propery from the root
  • Update existing tests and fixtures to use v2-compliant return values
  • Refactor mocks to align better with OIP style
  • Add data migration (strip version number from existing API roots)

@pi-sigma pi-sigma marked this pull request as ready for review February 12, 2024 10:11
@pi-sigma pi-sigma requested a review from stevenbal February 12, 2024 10:12
src/open_inwoner/kvk/tests/mocks.py Show resolved Hide resolved
src/open_inwoner/kvk/models.py Outdated Show resolved Hide resolved
Comment on lines 7 to 12
regexes = (
re.compile(r"^https://api.kvk.nl/api$"),
re.compile(r"^https://api.kvk.nl/api/$"),
re.compile(r"^https://api.kvk.nl/test/api$"),
re.compile(r"^https://api.kvk.nl/test/api/$"),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're going to restrict the API root to these values, I think it's better to define choices for the field and let people select one of these four.

I'm trying to think of a case where we'd want to use something else but can't really come up with one, is it necessary though to restrict the API root to these four values? It would be a hassle if we have to do a new release just to allow a different value here 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the validation more general. I couldn't think of any reason for supporting other roots, but better safe than sorry.

@pi-sigma pi-sigma force-pushed the upgrade/2069-kvk branch 3 times, most recently from 7fc50e9 to ae0d71a Compare February 16, 2024 14:24
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f62132f) 94.83% compared to head (2ca5293) 94.90%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1016      +/-   ##
===========================================
+ Coverage    94.83%   94.90%   +0.06%     
===========================================
  Files          880      885       +5     
  Lines        30704    30766      +62     
===========================================
+ Hits         29119    29197      +78     
+ Misses        1585     1569      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pi-sigma pi-sigma force-pushed the upgrade/2069-kvk branch 3 times, most recently from 9323f16 to 9dcc55a Compare February 19, 2024 10:38
    * Add validation for api root (exclude version number + endpoint)
    * Fix tests to ensure that api endpoints are constructed properly
    * strip version number from existing API roots
Copy link
Contributor

@stevenbal stevenbal left a comment

Choose a reason for hiding this comment

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

Minor remark regarding mocks.simple. Looks good otherwise 👍

It might be useful for us at some point in the future to look into adding VCR.py (https://vcrpy.readthedocs.io/en/latest/), to deal with mocks and to make them more realistic instead of having to maintain them manually. Open Forms uses this as well

Comment on lines +65 to +67
# via
# -r requirements/base.in
# mail-editor
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably from another PR? Doesn't actually change anything though, so it's fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Double-checked: I branched off upgrade/django-admin-index instead of develop when starting on this. The PR has been merged though.

src/open_inwoner/kvk/tests/mocks.py Show resolved Hide resolved
@stevenbal stevenbal self-requested a review February 20, 2024 08:12
@pi-sigma pi-sigma merged commit 3c780d7 into develop Feb 20, 2024
17 checks passed
@pi-sigma pi-sigma deleted the upgrade/2069-kvk branch February 20, 2024 08:58
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.

3 participants