Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/core/tests/__init__.py
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | def assertSnapshotOk(self, expected_snapshot, expected_branches=[]): | ||||
'target_type': target_type | 'target_type': target_type | ||||
} | } | ||||
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) | ||||
zack: I realize this it not a problem introduced by this diffs, but FWIW the naming of all these… | |||||
Done Inline ActionsDone in D772 vlorentz: Done in D772 | |||||
def assertOriginMetadataContains(self, origin_type, origin_url, | |||||
expected_origin_metadata): | |||||
"""Checks the storage contains this metadata for the given origin. | |||||
Args: | |||||
origin_type (str): type of origin ('deposit', 'git', 'svn', ...) | |||||
origin_url (str): URL of the origin | |||||
expected_origin_metadata (dict): | |||||
Extrinsic metadata of the origin | |||||
<https://forge.softwareheritage.org/T1344> | |||||
""" | |||||
origin = self.storage.origin_get( | |||||
dict(type=origin_type, url=origin_url)) | |||||
results = self.storage.origin_metadata_get_by(origin) | |||||
self.assertEqual(len(results), 1, results) | |||||
result = results[0] | |||||
self.assertEqual(result['metadata'], expected_origin_metadata) | |||||
@pytest.mark.fs | @pytest.mark.fs | ||||
class BaseLoaderTest(TestCase, BaseLoaderStorageTest): | class BaseLoaderTest(TestCase, BaseLoaderStorageTest): | ||||
"""Mixin base loader test class. | """Mixin base loader test class. | ||||
This allows to uncompress archives (mercurial, svn, git, | This allows to uncompress archives (mercurial, svn, git, | ||||
... repositories) into a temporary folder so that the loader under | ... repositories) into a temporary folder so that the loader under | ||||
test can work with this. | test can work with this. | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |
I realize this it not a problem introduced by this diffs, but FWIW the naming of all these assertion should be assertFooEqual, not assertFooOk, because that is what they're testing.
If would be just awesome if you could take the chance of this change to refactor that :-)
Your example, though, makes this distinction particularly relevant. Because for metadata (which are dictionaries) it would make sense to both asserts equality and to assert that the expected metadata are a subset of the obtained one, as in the future we might end up detecting more metadata, and making old tests failing only due to that might not be what we want, at least in some cases.