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 some helper methods to load and save config settings #1472

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

jonathangreen
Copy link
Member

Description

While I was working on PP-501, I noticed we are loading / updating config settings in a number of places. This centralizes that in a couple functions, and adds classmethods for them to HasIntegrationConfiguration.

Motivation and Context

Easier to work with integration settings.

How Has This Been Tested?

  • Running tests in CI

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen requested a review from a team October 19, 2023 18:51
@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (cbfaab1) 90.40% compared to head (878f958) 90.40%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1472   +/-   ##
=======================================
  Coverage   90.40%   90.40%           
=======================================
  Files         231      231           
  Lines       29718    29743   +25     
  Branches     6874     6878    +4     
=======================================
+ Hits        26866    26890   +24     
- Misses       1822     1824    +2     
+ Partials     1030     1029    -1     
Flag Coverage Δ
Api 74.07% <94.11%> (+0.01%) ⬆️
Core 61.01% <79.41%> (+0.01%) ⬆️
migration 28.93% <50.00%> (+0.02%) ⬆️

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

Files Coverage Δ
...admin/controller/patron_auth_service_self_tests.py 94.20% <100.00%> (ø)
api/discovery/opds_registration.py 95.60% <100.00%> (ø)
core/model/library.py 97.14% <100.00%> (-0.02%) ⬇️
core/opds_import.py 89.60% <100.00%> (+0.01%) ⬆️
core/integration/base.py 96.22% <92.30%> (-3.78%) ⬇️

... and 1 file with indirect coverage changes

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

Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

Looks good to me!

assert isinstance(not_configured, CannotLoadConfiguration)
assert "Could not instantiate MilleniumPatronAPI" in str(not_configured)

# The integration has left it trace in initialization_exceptions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: typo -> "...left [its] trace..."

@@ -210,7 +210,7 @@ def test_libraries_get_with_multiple_libraries(
FacetConstants.ORDER_TITLE,
FacetConstants.ORDER_AUTHOR,
] == settings_dict.get("facets_enabled_order")
assert ["French"] == settings_dict.get("large_collection_languages")
assert ["fre"] == settings_dict.get("large_collection_languages")
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not obvious why this has changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

It changed because the call to update settings on line 176 now validates the settings before saving, which normalizes the language codes. That normalization is tested elsewhere, so I think its fine to just update the test here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine, too. I just didn't understand it.

@jonathangreen jonathangreen merged commit 1b835b0 into main Oct 19, 2023
30 checks passed
@jonathangreen jonathangreen deleted the feature/integration-settings-load-save branch October 19, 2023 23:52
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