Skip to content

Commit

Permalink
Fix bug with settings in MARCExporter (PP-306) (#1322)
Browse files Browse the repository at this point in the history
In #1303 I mistakenly updated a call to settings on an ExternalIntegration to a call to settings_dict.

This PR fixes the issue, and adds a test for the function that the issue occurred in, since it wasn't tested before.
  • Loading branch information
jonathangreen authored Aug 10, 2023
1 parent 0ed3967 commit 8974bae
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/marc.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def get_storage_settings(cls, _db):
# Only add an integration to choose from if it has a
# MARC File Bucket field in its settings.
configuration_settings = [
s for s in integration.settings_dict if s.key == "marc_bucket"
s for s in integration.settings if s.key == "marc_bucket"
]

if configuration_settings:
Expand Down
32 changes: 32 additions & 0 deletions tests/core/test_marc.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,38 @@ def test_records(self, db: DatabaseTransactionFixture):

db.session.delete(cache)

def test_get_storage_settings(self, db: DatabaseTransactionFixture):
# Two ExternalIntegration, one has a marc_bucket setting, and the
# other doesn't.
has_marc_bucket = db.external_integration(
name="has_marc_bucket",
protocol=db.fresh_str(),
goal=ExternalIntegration.STORAGE_GOAL,
settings={"marc_bucket": "test-marc-bucket"},
)
db.external_integration(
name="no_marc_bucket",
protocol=db.fresh_str(),
goal=ExternalIntegration.STORAGE_GOAL,
)

# Before we call get_storage_settings, the only option is the default.
assert MARCExporter.SETTING["options"] == [
MARCExporter.DEFAULT_MIRROR_INTEGRATION
]

MARCExporter.get_storage_settings(db.session)

# After we call get_storage_settings, the options are the default and
# the ExternalIntegration with a marc_bucket setting.
assert len(MARCExporter.SETTING["options"]) == 2
[default, from_config] = MARCExporter.SETTING["options"]
assert default == MARCExporter.DEFAULT_MIRROR_INTEGRATION
assert from_config == {
"key": str(has_marc_bucket.id),
"label": has_marc_bucket.name,
}


class TestMARCExporterFacets:
def test_modify_search_filter(self):
Expand Down

0 comments on commit 8974bae

Please sign in to comment.