diff --git a/swh/indexer/storage/__init__.py b/swh/indexer/storage/__init__.py --- a/swh/indexer/storage/__init__.py +++ b/swh/indexer/storage/__init__.py @@ -13,7 +13,6 @@ from swh.storage.common import db_transaction_generator, db_transaction from swh.storage.exc import StorageDBError from .db import Db -from ..metadata_dictionary import MAPPINGS from . import converters @@ -21,6 +20,9 @@ INDEXER_CFG_KEY = 'indexer_storage' +MAPPING_NAMES = ['codemeta', 'gemspec', 'maven', 'npm', 'pkg-info'] + + def get_indexer_storage(cls, args): """Get an indexer storage object of class `storage_class` with arguments `storage_args`. @@ -756,7 +758,7 @@ mapping. Note that indexing a given origin may use 0, 1, or many mappings. """ - mapping_names = [m.name for m in MAPPINGS.values()] + mapping_names = [m for m in MAPPING_NAMES] select_parts = [] # Count rows for each mapping diff --git a/swh/indexer/storage/in_memory.py b/swh/indexer/storage/in_memory.py --- a/swh/indexer/storage/in_memory.py +++ b/swh/indexer/storage/in_memory.py @@ -11,7 +11,7 @@ import math import re -from ..metadata_dictionary import MAPPINGS +from . import MAPPING_NAMES SHA1_DIGEST_SIZE = 160 @@ -683,7 +683,7 @@ mapping. Note that indexing a given origin may use 0, 1, or many mappings. """ - mapping_count = {m.name: 0 for m in MAPPINGS.values()} + mapping_count = {m: 0 for m in MAPPING_NAMES} total = non_empty = 0 for data in self._origin_intrinsic_metadata.get_all(): total += 1 diff --git a/swh/indexer/tests/storage/test_storage.py b/swh/indexer/tests/storage/test_storage.py --- a/swh/indexer/tests/storage/test_storage.py +++ b/swh/indexer/tests/storage/test_storage.py @@ -11,12 +11,13 @@ from swh.model.hashutil import hash_to_bytes -from swh.indexer.storage import get_indexer_storage +from swh.indexer.storage import get_indexer_storage, MAPPING_NAMES from swh.core.tests.db_testing import SingleDbTestFixture from swh.indexer.tests.storage.generate_data_test import ( gen_content_mimetypes, gen_content_fossology_licenses ) from swh.indexer.tests.storage import SQL_DIR +from swh.indexer.metadata_dictionary import MAPPINGS TOOLS = [ { @@ -1594,3 +1595,7 @@ """ pass + + +def test_mapping_names(): + assert set(MAPPING_NAMES) == {m.name for m in MAPPINGS.values()}