Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/test_origin_head.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-2018 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import unittest | import unittest | ||||
from swh.indexer.origin_head import OriginHeadIndexer | from swh.indexer.origin_head import OriginHeadIndexer | ||||
from swh.indexer.tests.utils import ( | from swh.indexer.tests.utils import ( | ||||
BASE_TEST_CONFIG, fill_storage | BASE_TEST_CONFIG, fill_storage | ||||
) | ) | ||||
ORIGIN_HEAD_CONFIG = { | |||||
class OriginHeadTestIndexer(OriginHeadIndexer): | |||||
"""Specific indexer whose configuration is enough to satisfy the | |||||
indexing tests. | |||||
""" | |||||
def parse_config_file(self, *args, **kwargs): | |||||
return { | |||||
**BASE_TEST_CONFIG, | **BASE_TEST_CONFIG, | ||||
'tools': { | 'tools': { | ||||
'name': 'origin-metadata', | 'name': 'origin-metadata', | ||||
'version': '0.0.1', | 'version': '0.0.1', | ||||
'configuration': {}, | 'configuration': {}, | ||||
}, | }, | ||||
'tasks': { | 'tasks': { | ||||
'revision_metadata': None, | 'revision_metadata': None, | ||||
'origin_intrinsic_metadata': None, | 'origin_intrinsic_metadata': None, | ||||
} | } | ||||
} | } | ||||
class OriginHeadTestIndexer(OriginHeadIndexer): | |||||
"""Specific indexer whose configuration is enough to satisfy the | |||||
indexing tests. | |||||
""" | |||||
def parse_config_file(self, *args, **kwargs): | |||||
return ORIGIN_HEAD_CONFIG | |||||
def persist_index_computations(self, results, policy_update): | def persist_index_computations(self, results, policy_update): | ||||
self.results = results | self.results = results | ||||
class OriginHead(unittest.TestCase): | class OriginHead(unittest.TestCase): | ||||
def setUp(self): | def setUp(self): | ||||
self.indexer = OriginHeadTestIndexer() | self.indexer = OriginHeadTestIndexer() | ||||
fill_storage(self.indexer.storage) | fill_storage(self.indexer.storage) | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |