Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/tar/tests/test_loader.py
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | def assert_data_ok(self): | ||||
'sha1': '3ca0d0a5c6833113bd532dc5c99d9648d618f65a', | 'sha1': '3ca0d0a5c6833113bd532dc5c99d9648d618f65a', | ||||
'length': 555, | 'length': 555, | ||||
'sha256': '307ebda0071ca5975f618e192c8417161e19b6c8bf581a26061b76dc8e85321d' # noqa | 'sha256': '307ebda0071ca5975f618e192c8417161e19b6c8bf581a26061b76dc8e85321d' # noqa | ||||
}) | }) | ||||
self.assertCountReleases(0) | self.assertCountReleases(0) | ||||
self.assertCountSnapshots(1) | self.assertCountSnapshots(1) | ||||
return actual_revision | |||||
class TestRemoteTarLoader(PrepareDataForTestLoader): | class TestRemoteTarLoader(PrepareDataForTestLoader): | ||||
"""Test the remote loader scenario (local/remote) | """Test the remote loader scenario (local/remote) | ||||
""" | """ | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp() | super().setUp() | ||||
self.loader = RemoteTarLoaderForTest() | self.loader = RemoteTarLoaderForTest() | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | class TestTarLoader(PrepareDataForTestLoader): | ||||
def setUp(self): | def setUp(self): | ||||
super().setUp() | super().setUp() | ||||
self.loader = TarLoaderForTest() | self.loader = TarLoaderForTest() | ||||
self.storage = self.loader.storage | self.storage = self.loader.storage | ||||
def test_load(self): | def test_load(self): | ||||
"""Load a local tarball should result in persisted swh data | """Load a local tarball should result in persisted swh data | ||||
""" | """ | ||||
# given | # given | ||||
origin = { | origin = { | ||||
'url': self.repo_url, | 'url': self.repo_url, | ||||
'type': 'tar' | 'type': 'tar' | ||||
} | } | ||||
visit_date = 'Tue, 3 May 2016 17:16:32 +0200' | visit_date = 'Tue, 3 May 2016 17:16:32 +0200' | ||||
Show All 15 Lines | def test_load(self): | ||||
'timestamp': commit_time, | 'timestamp': commit_time, | ||||
'offset': 0, | 'offset': 0, | ||||
}, | }, | ||||
'author': SWH_PERSON, | 'author': SWH_PERSON, | ||||
'committer': SWH_PERSON, | 'committer': SWH_PERSON, | ||||
'type': revision_type, | 'type': revision_type, | ||||
'message': revision_message, | 'message': revision_message, | ||||
'synthetic': True, | 'synthetic': True, | ||||
'metadata': { | |||||
'foo': 'bar', | |||||
'original_artifact': ['bogus_original_artifact'], | |||||
} | |||||
} | } | ||||
branch_name = os.path.basename(self.tarpath) | branch_name = os.path.basename(self.tarpath) | ||||
# when | # when | ||||
self.loader.load(tar_path=self.tarpath, origin=origin, | self.loader.load(tar_path=self.tarpath, origin=origin, | ||||
visit_date=visit_date, revision=revision, | visit_date=visit_date, revision=revision, | ||||
branch_name=branch_name) | branch_name=branch_name) | ||||
# then | # then | ||||
self.assert_data_ok() | actual_revision = self.assert_data_ok() | ||||
# Check metadata passthrough | |||||
assert actual_revision['metadata']['foo'] == 'bar' | |||||
# FIXME: use the caplog pytest fixture to check that the clobbering of | |||||
# original artifact sent a warning |