Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/data.py
Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | _TEST_ORIGINS = [ | ||||
} | } | ||||
] | ] | ||||
_contents = {} | _contents = {} | ||||
# Tests data initialization | # Tests data initialization | ||||
def _init_tests_data(): | def _init_tests_data(): | ||||
# Load git repositories from archives | # To hold reference to the memory storage | ||||
loader = GitLoaderFromArchive(config=_TEST_LOADER_CONFIG) | storage = None | ||||
# Get reference to the memory storage | |||||
storage = loader.storage | |||||
# Load git repositories from archives | |||||
for origin in _TEST_ORIGINS: | for origin in _TEST_ORIGINS: | ||||
for i, archive in enumerate(origin['archives']): | for i, archive in enumerate(origin['archives']): | ||||
origin_repo_archive = \ | origin_repo_archive = \ | ||||
os.path.join(os.path.dirname(__file__), | os.path.join(os.path.dirname(__file__), | ||||
'resources/repos/%s' % archive) | 'resources/repos/%s' % archive) | ||||
loader.load(origin['url'], origin_repo_archive, | loader = GitLoaderFromArchive(origin['url'], | ||||
origin['visit_date'][i]) | archive_path=origin_repo_archive, | ||||
config=_TEST_LOADER_CONFIG, | |||||
visit_date=origin['visit_date'][i]) | |||||
if storage is None: | |||||
storage = loader.storage | |||||
else: | |||||
loader.storage = storage | |||||
loader.load() | |||||
origin.update(storage.origin_get(origin)) # add an 'id' key if enabled | origin.update(storage.origin_get(origin)) # add an 'id' key if enabled | ||||
for i in range(250): | for i in range(250): | ||||
url = 'https://many.origins/%d' % (i+1) | url = 'https://many.origins/%d' % (i+1) | ||||
storage.origin_add([{'url': url}]) | storage.origin_add([{'url': url}]) | ||||
visit = storage.origin_visit_add(url, '2019-12-03 13:55:05', 'tar') | visit = storage.origin_visit_add(url, '2019-12-03 13:55:05', 'tar') | ||||
storage.origin_visit_update( | storage.origin_visit_update( | ||||
▲ Show 20 Lines • Show All 282 Lines • Show Last 20 Lines |