Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/__init__.py
# Copyright (C) 2017 The Software Heritage developers | # Copyright (C) 2017-2019 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 | ||||
from swh.deposit.config import setup_django_for | from swh.deposit.config import setup_django_for | ||||
from swh.deposit.config import SWHDefaultConfig # noqa | from swh.deposit.config import SWHDefaultConfig # noqa | ||||
from swh.loader.core.loader import BufferedLoader | |||||
TEST_CONFIG = { | TEST_CONFIG = { | ||||
'max_upload_size': 500, | 'max_upload_size': 500, | ||||
'extraction_dir': '/tmp/swh-deposit/test/extraction-dir', | 'extraction_dir': '/tmp/swh-deposit/test/extraction-dir', | ||||
'checks': False, | 'checks': False, | ||||
'provider': { | 'provider': { | ||||
'provider_name': '', | 'provider_name': '', | ||||
'provider_type': 'deposit_client', | 'provider_type': 'deposit_client', | ||||
Show All 11 Lines | |||||
} | } | ||||
def parse_deposit_config_file(base_filename=None, config_filename=None, | def parse_deposit_config_file(base_filename=None, config_filename=None, | ||||
additional_configs=None, global_config=True): | additional_configs=None, global_config=True): | ||||
return TEST_CONFIG | return TEST_CONFIG | ||||
TEST_LOADER_CONFIG = { | |||||
'extraction_dir': '/tmp/swh-loader-tar/test/', | |||||
'working_dir': '/tmp/swh-loader-tar/test/working-dir', | |||||
'debug': False, | |||||
'storage': { | |||||
'cls': 'memory', | |||||
'args': { | |||||
} | |||||
}, | |||||
'send_contents': True, | |||||
'send_directories': True, | |||||
'send_revisions': True, | |||||
'send_releases': True, | |||||
'send_snapshot': True, | |||||
'content_size_limit': 100 * 1024 * 1024, | |||||
'content_packet_size': 10, | |||||
'content_packet_size_bytes': 100 * 1024 * 1024, | |||||
'directory_packet_size': 10, | |||||
'revision_packet_size': 10, | |||||
'release_packet_size': 10, | |||||
} | |||||
def parse_loader_config_file(base_filename=None, config_filename=None, | |||||
additional_configs=None, global_config=True): | |||||
return TEST_LOADER_CONFIG | |||||
# monkey patch classes method permits to override, for tests purposes, | # monkey patch classes method permits to override, for tests purposes, | ||||
# the default configuration without side-effect, i.e do not load the | # the default configuration without side-effect, i.e do not load the | ||||
# configuration from disk | # configuration from disk | ||||
SWHDefaultConfig.parse_config_file = parse_deposit_config_file # type: ignore | SWHDefaultConfig.parse_config_file = parse_deposit_config_file # type: ignore | ||||
BufferedLoader.parse_config_file = parse_loader_config_file # type: ignore | |||||
setup_django_for('testing') | setup_django_for('testing') |