Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_metadata.py
Show All 32 Lines | |||||
class ContentMetadataTestIndexer(ContentMetadataIndexer): | class ContentMetadataTestIndexer(ContentMetadataIndexer): | ||||
"""Specific Metadata whose configuration is enough to satisfy the | """Specific Metadata whose configuration is enough to satisfy the | ||||
indexing tests. | indexing tests. | ||||
""" | """ | ||||
def parse_config_file(self, *args, **kwargs): | def parse_config_file(self, *args, **kwargs): | ||||
assert False, 'should not be called; the rev indexer configures it.' | assert False, 'should not be called; the rev indexer configures it.' | ||||
class RevisionMetadataTestIndexer(RevisionMetadataIndexer): | REVISION_METADATA_CONFIG = { | ||||
"""Specific indexer whose configuration is enough to satisfy the | |||||
indexing tests. | |||||
""" | |||||
ContentMetadataIndexer = ContentMetadataTestIndexer | |||||
def parse_config_file(self, *args, **kwargs): | |||||
return { | |||||
**BASE_TEST_CONFIG, | **BASE_TEST_CONFIG, | ||||
'tools': TRANSLATOR_TOOL, | 'tools': TRANSLATOR_TOOL, | ||||
} | } | ||||
class Metadata(unittest.TestCase): | class Metadata(unittest.TestCase): | ||||
""" | """ | ||||
Tests metadata_mock_tool tool for Metadata detection | Tests metadata_mock_tool tool for Metadata detection | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 678 Lines • ▼ Show 20 Lines | """) # noqa | ||||
self.assertEqual(result, { | self.assertEqual(result, { | ||||
'@context': 'https://doi.org/10.5063/schema/codemeta-2.0', | '@context': 'https://doi.org/10.5063/schema/codemeta-2.0', | ||||
'type': 'SoftwareSourceCode', | 'type': 'SoftwareSourceCode', | ||||
'name': 'foo', | 'name': 'foo', | ||||
'license': 'MIT', | 'license': 'MIT', | ||||
}) | }) | ||||
def test_revision_metadata_indexer(self): | def test_revision_metadata_indexer(self): | ||||
metadata_indexer = RevisionMetadataTestIndexer() | metadata_indexer = RevisionMetadataIndexer( | ||||
config=REVISION_METADATA_CONFIG) | |||||
fill_obj_storage(metadata_indexer.objstorage) | fill_obj_storage(metadata_indexer.objstorage) | ||||
fill_storage(metadata_indexer.storage) | fill_storage(metadata_indexer.storage) | ||||
tool = metadata_indexer.idx_storage.indexer_configuration_get( | tool = metadata_indexer.idx_storage.indexer_configuration_get( | ||||
{'tool_'+k: v for (k, v) in TRANSLATOR_TOOL.items()}) | {'tool_'+k: v for (k, v) in TRANSLATOR_TOOL.items()}) | ||||
assert tool is not None | assert tool is not None | ||||
metadata_indexer.idx_storage.content_metadata_add([{ | metadata_indexer.idx_storage.content_metadata_add([{ | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |