Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/mercurial/tests/test_loader.py
# Copyright (C) 2018 The Software Heritage developers | # Copyright (C) 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 os | import os | ||||
from swh.loader.core.tests import BaseLoaderTest | from swh.loader.core.tests import BaseLoaderTest | ||||
from swh.loader.mercurial.loader import HgBundle20Loader | from .common import HgLoaderMemoryStorage | ||||
_LOADER_TEST_CONFIG = { | |||||
'bundle_filename': 'HG20_none_bundle', | |||||
'cache1_size': 838860800, | |||||
'cache2_size': 838860800, | |||||
'content_packet_size': 100000, | |||||
'content_packet_size_bytes': 1073741824, | |||||
'content_size_limit': 104857600, | |||||
'directory_packet_size': 25000, | |||||
'log_db': 'dbname=softwareheritage-log', | |||||
'occurrence_packet_size': 100000, | |||||
'reduce_effort': False, | |||||
'release_packet_size': 100000, | |||||
'revision_packet_size': 100000, | |||||
'save_data': False, | |||||
'save_data_path': '', | |||||
'send_contents': True, | |||||
'send_directories': True, | |||||
'send_occurrences': True, | |||||
'send_releases': True, | |||||
'send_revisions': True, | |||||
'send_snapshot': True, | |||||
'storage': {'args': {}, 'cls': 'memory'}, | |||||
'temp_directory': '/tmp/swh.loader.mercurial' | |||||
} | |||||
class HgLoaderMemoryStorage(HgBundle20Loader): | |||||
"""The mercurial loader to test. | |||||
Its behavior has been changed to: | |||||
- not use any persistence (no storage, or for now a passthrough | |||||
storage with no filtering) | |||||
- not use the default configuration loading | |||||
At the end of the tests, you can make sure you have the rights | |||||
objects. | |||||
""" | |||||
def __init__(self): | |||||
super().__init__() | |||||
self.origin_id = 1 | |||||
self.visit = 1 | |||||
def parse_config_file(self, *args, **kwargs): | |||||
return _LOADER_TEST_CONFIG | |||||
class BaseHgLoaderTest(BaseLoaderTest): | class BaseHgLoaderTest(BaseLoaderTest): | ||||
"""Mixin base loader test to prepare the mercurial | """Mixin base loader test to prepare the mercurial | ||||
repository to uncompress, load and test the results. | repository to uncompress, load and test the results. | ||||
This sets up | This sets up | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | def test_load(self): | ||||
'target': 'default', | 'target': 'default', | ||||
'target_type': 'alias', | 'target_type': 'alias', | ||||
} | } | ||||
} | } | ||||
} | } | ||||
self.assertSnapshotEqual(expected_snapshot) | self.assertSnapshotEqual(expected_snapshot) | ||||
self.assertEqual(self.loader.load_status(), {'status': 'eventful'}) | self.assertEqual(self.loader.load_status(), {'status': 'eventful'}) | ||||
self.assertEqual(self.loader.visit_status(), 'full') | self.assertEqual(self.loader.visit_status(), 'full') | ||||
anlambert: Small nitpick, I would rename 'LoaderITest2' into 'LoaderTest2' here and do the same for all… | |||||
Done Inline ActionsRight. The I stands for integration. ardumont: Right.
The I stands for integration. |
Small nitpick, I would rename 'LoaderITest2' into 'LoaderTest2' here and do the same for all test class names.
I don't see the point of that extra 'I' character.