Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/core/tests/test_loader.py
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
class DummyBaseLoaderTest(BaseLoaderTest): | class DummyBaseLoaderTest(BaseLoaderTest): | ||||
def setUp(self): | def setUp(self): | ||||
self.loader = self.loader_class(logging_class='dummyloader') | self.loader = self.loader_class(logging_class='dummyloader') | ||||
self.loader.visit_type = 'git' | self.loader.visit_type = 'git' | ||||
# do not call voluntarily super().setUp() | # do not call voluntarily super().setUp() | ||||
self.storage = self.loader.storage | self.storage = self.loader.storage | ||||
contents = [ | contents = [ | ||||
{ | { | ||||
'id': '34973274ccef6ab4dfaaf86599792fa9c3fe4689', | |||||
'sha1': '34973274ccef6ab4dfaaf86599792fa9c3fe4689', | 'sha1': '34973274ccef6ab4dfaaf86599792fa9c3fe4689', | ||||
'sha1_git': b'bar1', | 'sha1_git': b'bar1', | ||||
'sha256': b'baz1', | 'sha256': b'baz1', | ||||
'blake2s256': b'qux1', | 'blake2s256': b'qux1', | ||||
'status': 'visible', | 'status': 'visible', | ||||
'data': b'data1', | 'data': b'data1', | ||||
'length': 5, | 'length': 5, | ||||
}, | }, | ||||
{ | { | ||||
'id': '61c2b3a30496d329e21af70dd2d7e097046d07b7', | |||||
'sha1': '61c2b3a30496d329e21af70dd2d7e097046d07b7', | 'sha1': '61c2b3a30496d329e21af70dd2d7e097046d07b7', | ||||
'sha1_git': b'bar2', | 'sha1_git': b'bar2', | ||||
'sha256': b'baz2', | 'sha256': b'baz2', | ||||
'blake2s256': b'qux2', | 'blake2s256': b'qux2', | ||||
'status': 'visible', | 'status': 'visible', | ||||
'data': b'data2', | 'data': b'data2', | ||||
'length': 5, | 'length': 5, | ||||
}, | }, | ||||
] | ] | ||||
self.expected_contents = [content['id'] for content in contents] | self.expected_contents = [content['sha1'] for content in contents] | ||||
self.in_contents = contents.copy() | self.in_contents = contents.copy() | ||||
for content in self.in_contents: | for content in self.in_contents: | ||||
content['sha1'] = hash_to_bytes(content['sha1']) | content['sha1'] = hash_to_bytes(content['sha1']) | ||||
self.in_directories = [ | self.in_directories = [ | ||||
{'id': hash_to_bytes(id_)} | {'id': hash_to_bytes(id_), 'entries': []} | ||||
for id_ in [ | for id_ in [ | ||||
'44e45d56f88993aae6a0198013efa80716fd8921', | '44e45d56f88993aae6a0198013efa80716fd8921', | ||||
'54e45d56f88993aae6a0198013efa80716fd8920', | '54e45d56f88993aae6a0198013efa80716fd8920', | ||||
'43e45d56f88993aae6a0198013efa80716fd8920', | '43e45d56f88993aae6a0198013efa80716fd8920', | ||||
] | ] | ||||
] | ] | ||||
person = { | person = { | ||||
'name': b'John Doe', | 'name': b'John Doe', | ||||
'email': b'john.doe@institute.org', | 'email': b'john.doe@institute.org', | ||||
'fullname': b'John Doe <john.doe@institute.org>' | 'fullname': b'John Doe <john.doe@institute.org>' | ||||
} | } | ||||
rev1_id = b'\x00'*20 | |||||
rev2_id = b'\x01'*20 | |||||
self.in_revisions = [ | self.in_revisions = [ | ||||
{ | { | ||||
'id': b'rev1', | 'id': rev1_id, | ||||
'date': None, | 'type': 'git', | ||||
'date': 1567591673, | |||||
'committer_date': 1567591673, | |||||
'author': person, | 'author': person, | ||||
'committer': person | 'committer': person, | ||||
'message': b'msg1', | |||||
'directory': None, | |||||
'synthetic': False, | |||||
'metadata': None, | |||||
'parents': [], | |||||
}, | }, | ||||
{ | { | ||||
'id': b'rev2', | 'id': rev2_id, | ||||
'date': None, | 'type': 'hg', | ||||
'date': 1567591673, | |||||
'committer_date': 1567591673, | |||||
'author': person, | 'author': person, | ||||
'committer': person | 'committer': person, | ||||
'message': b'msg2', | |||||
'directory': None, | |||||
'synthetic': False, | |||||
'metadata': None, | |||||
'parents': [], | |||||
}, | }, | ||||
] | ] | ||||
self.in_releases = [ | self.in_releases = [ | ||||
{ | { | ||||
'id': b'rel1', | 'name': b'rel1', | ||||
'id': b'\x02'*20, | |||||
'date': None, | 'date': None, | ||||
'author': person | 'author': person, | ||||
'target_type': 'revision', | |||||
'target': rev1_id, | |||||
'message': None, | |||||
'synthetic': False, | |||||
}, | }, | ||||
{ | { | ||||
'id': b'rel2', | 'name': b'rel2', | ||||
'id': b'\x03'*20, | |||||
'date': None, | 'date': None, | ||||
'author': person | 'author': person, | ||||
'target_type': 'revision', | |||||
'target': rev2_id, | |||||
'message': None, | |||||
'synthetic': False, | |||||
}, | }, | ||||
] | ] | ||||
self.in_origin = { | self.in_origin = { | ||||
'type': self.loader.visit_type, | 'type': self.loader.visit_type, | ||||
'url': 'http://example.com/', | 'url': 'http://example.com/', | ||||
} | } | ||||
self.in_snapshot = { | self.in_snapshot = { | ||||
'id': b'snap1', | 'id': b'snap1', | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |