diff --git a/core/marc.py b/core/marc.py index 85598035ba..ccb1d89472 100644 --- a/core/marc.py +++ b/core/marc.py @@ -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: diff --git a/tests/core/test_marc.py b/tests/core/test_marc.py index dc6000a202..29f78d7c5b 100644 --- a/tests/core/test_marc.py +++ b/tests/core/test_marc.py @@ -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):