Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/core/tests/__init__.py
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | def assertSnapshotEqual(self, expected_snapshot, expected_branches=[]): | ||||
} | } | ||||
branches = { | branches = { | ||||
branch.decode('utf-8'): decode_target(target) | branch.decode('utf-8'): decode_target(target) | ||||
for branch, target in snap['branches'].items() | for branch, target in snap['branches'].items() | ||||
} | } | ||||
self.assertEqual(expected_branches, branches) | self.assertEqual(expected_branches, branches) | ||||
def assertOriginMetadataContains(self, origin_type, origin_url, | def assertOriginMetadataContains(self, origin_url, | ||||
expected_origin_metadata): | expected_origin_metadata): | ||||
"""Check the storage contains this metadata for the given origin. | """Check the storage contains this metadata for the given origin. | ||||
Args: | Args: | ||||
origin_type (str): type of origin ('deposit', 'git', 'svn', ...) | |||||
origin_url (str): URL of the origin | origin_url (str): URL of the origin | ||||
expected_origin_metadata (dict): | expected_origin_metadata (dict): | ||||
Extrinsic metadata of the origin | Extrinsic metadata of the origin | ||||
<https://forge.softwareheritage.org/T1344> | <https://forge.softwareheritage.org/T1344> | ||||
""" | """ | ||||
origin = self.storage.origin_get( | origin = self.storage.origin_get({'url': origin_url}) | ||||
dict(type=origin_type, url=origin_url)) | |||||
results = self.storage.origin_metadata_get_by(origin['url']) | results = self.storage.origin_metadata_get_by(origin['url']) | ||||
self.assertEqual(len(results), 1, results) | self.assertEqual(len(results), 1, results) | ||||
result = results[0] | result = results[0] | ||||
self.assertEqual(result['metadata'], expected_origin_metadata) | self.assertEqual(result['metadata'], expected_origin_metadata) | ||||
@pytest.mark.fs | @pytest.mark.fs | ||||
class BaseLoaderTest(TestCase, BaseLoaderStorageTest): | class BaseLoaderTest(TestCase, BaseLoaderStorageTest): | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |