@override_settings(REFERENCE_DATA_SOURCES=TEST_DATA_SOURCES)
def test_import_all(mock_importers):
call_command("index_reference_data")
mock_importers["Finto"].assert_has_calls(
[
call(
model=FieldOfScience,
source=TEST_DATA_SOURCES["field_of_science"]["source"],
scheme=None,
),
call(
model=Theme,
source=TEST_DATA_SOURCES["theme"]["source"],
scheme=None,
),
]
)
mock_importers["FintoLocation"].assert_called_once_with(
model=Location,
source=TEST_DATA_SOURCES["location"]["source"],
scheme=None,
)
mock_importers["LocalJSON"].assert_called_once_with(
model=AccessType,
source=TEST_DATA_SOURCES["access_type"]["source"],
scheme=TEST_DATA_SOURCES["access_type"]["scheme"],
)
mock_importers["LocalJSONLicense"].assert_called_once_with(
model=License,
source=TEST_DATA_SOURCES["license"]["source"],
scheme=TEST_DATA_SOURCES["license"]["scheme"],
)
mock_importers["LocalJSONFileFormatVersion"].assert_called_once_with(
model=FileFormatVersion,
source=TEST_DATA_SOURCES["file_format_version"]["source"],
scheme=TEST_DATA_SOURCES["file_format_version"]["scheme"],
)
for importer in mock_importers.values():
# Check .load() is called for an instance of each importer type
importer.return_value.load.assert_called()