Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/tests/utils.py
Show All 28 Lines | BASE_TEST_CONFIG = { | ||||
}, | }, | ||||
INDEXER_CFG_KEY: { | INDEXER_CFG_KEY: { | ||||
'cls': 'memory', | 'cls': 'memory', | ||||
'args': { | 'args': { | ||||
}, | }, | ||||
}, | }, | ||||
} | } | ||||
ORIGINS = [ | ORIGIN_VISITS = [ | ||||
{ | { | ||||
'type': 'git', | 'type': 'git', | ||||
'url': 'https://github.com/SoftwareHeritage/swh-storage'}, | 'url': 'https://github.com/SoftwareHeritage/swh-storage'}, | ||||
{ | { | ||||
'type': 'ftp', | 'type': 'ftp', | ||||
'url': 'rsync://ftp.gnu.org/gnu/3dldf'}, | 'url': 'rsync://ftp.gnu.org/gnu/3dldf'}, | ||||
{ | { | ||||
'type': 'deposit', | 'type': 'deposit', | ||||
▲ Show 20 Lines • Show All 490 Lines • ▼ Show 20 Lines | |||||
def fill_obj_storage(obj_storage): | def fill_obj_storage(obj_storage): | ||||
"""Add some content in an object storage.""" | """Add some content in an object storage.""" | ||||
for (obj_id, content) in OBJ_STORAGE_DATA.items(): | for (obj_id, content) in OBJ_STORAGE_DATA.items(): | ||||
obj_storage.add(content, obj_id=hash_to_bytes(obj_id)) | obj_storage.add(content, obj_id=hash_to_bytes(obj_id)) | ||||
def fill_storage(storage): | def fill_storage(storage): | ||||
for origin in ORIGINS: | visit_types = {} | ||||
vlorentz: 'type' should not be in origin | |||||
storage.origin_add_one(origin) | for visit in ORIGIN_VISITS: | ||||
storage.origin_add_one({'url': visit['url']}) | |||||
visit_types[visit['url']] = visit['type'] | |||||
for snap in SNAPSHOTS: | for snap in SNAPSHOTS: | ||||
origin_url = snap['origin'] | origin_url = snap['origin'] | ||||
visit = storage.origin_visit_add(origin_url, datetime.datetime.now()) | visit = storage.origin_visit_add( | ||||
origin=origin_url, | |||||
date=datetime.datetime.now(), | |||||
type=visit_types[origin_url]) | |||||
snap_id = snap.get('id') or \ | snap_id = snap.get('id') or \ | ||||
bytes([random.randint(0, 255) for _ in range(32)]) | bytes([random.randint(0, 255) for _ in range(32)]) | ||||
storage.snapshot_add([{ | storage.snapshot_add([{ | ||||
'id': snap_id, | 'id': snap_id, | ||||
'branches': snap['branches'] | 'branches': snap['branches'] | ||||
}]) | }]) | ||||
storage.origin_visit_update( | storage.origin_visit_update( | ||||
origin_url, visit['visit'], status='full', snapshot=snap_id) | origin_url, visit['visit'], status='full', snapshot=snap_id) | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |
'type' should not be in origin