Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/data.py
Show All 9 Lines | |||||
from swh.indexer.fossology_license import FossologyLicenseIndexer | from swh.indexer.fossology_license import FossologyLicenseIndexer | ||||
from swh.indexer.mimetype import MimetypeIndexer | from swh.indexer.mimetype import MimetypeIndexer | ||||
from swh.indexer.ctags import CtagsIndexer | from swh.indexer.ctags import CtagsIndexer | ||||
from swh.indexer.storage import get_indexer_storage | from swh.indexer.storage import get_indexer_storage | ||||
from swh.model.hashutil import hash_to_hex, hash_to_bytes, DEFAULT_ALGORITHMS | from swh.model.hashutil import hash_to_hex, hash_to_bytes, DEFAULT_ALGORITHMS | ||||
from swh.model.identifiers import directory_identifier | from swh.model.identifiers import directory_identifier | ||||
from swh.loader.git.from_disk import GitLoaderFromArchive | from swh.loader.git.from_disk import GitLoaderFromArchive | ||||
from swh.storage.algos.dir_iterators import dir_iterator | from swh.storage.algos.dir_iterators import dir_iterator | ||||
from swh.web import config | |||||
from swh.web.browse.utils import ( | from swh.web.browse.utils import ( | ||||
get_mimetype_and_encoding_for_content, prepare_content_for_display | get_mimetype_and_encoding_for_content, prepare_content_for_display | ||||
) | ) | ||||
from swh.web.common import service | |||||
# Module used to initialize data that will be provided as tests input | # Module used to initialize data that will be provided as tests input | ||||
# Configuration for git loader | # Configuration for git loader | ||||
_TEST_LOADER_CONFIG = { | _TEST_LOADER_CONFIG = { | ||||
'storage': { | 'storage': { | ||||
'cls': 'memory', | 'cls': 'memory', | ||||
'args': {} | 'args': {} | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | if _tests_data is None: | ||||
_indexer_loggers[name] = idx.log | _indexer_loggers[name] = idx.log | ||||
del idx.log | del idx.log | ||||
_tests_data.update(indexers) | _tests_data.update(indexers) | ||||
if reset or _current_tests_data is None: | if reset or _current_tests_data is None: | ||||
_current_tests_data = deepcopy(_tests_data) | _current_tests_data = deepcopy(_tests_data) | ||||
for (name, logger) in _indexer_loggers.items(): | for (name, logger) in _indexer_loggers.items(): | ||||
_current_tests_data[name].log = logger | _current_tests_data[name].log = logger | ||||
return _current_tests_data | return _current_tests_data | ||||
def override_storages(storage, idx_storage): | |||||
""" | |||||
Helper function to replace the storages from which archive data | |||||
are fetched. | |||||
""" | |||||
swh_config = config.get_config() | |||||
swh_config.update({'storage': storage}) | |||||
service.storage = storage | |||||
swh_config.update({'indexer_storage': idx_storage}) | |||||
service.idx_storage = idx_storage |