Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/tests/test_backend.py
Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | def content_find_occurrence(self): | ||||
# then | # then | ||||
self.assertEquals(actual_content, (1, 2, 3)) | self.assertEquals(actual_content, (1, 2, 3)) | ||||
# check the function has been called with parameters | # check the function has been called with parameters | ||||
self.storage.content_find_occurrence.assert_called_with( | self.storage.content_find_occurrence.assert_called_with( | ||||
{'sha1': sha1_bin}) | {'sha1': sha1_bin}) | ||||
@istest | @istest | ||||
def content_missing_per_sha1_none(self): | |||||
# given | |||||
sha1s_bin = [hashutil.hex_to_hash( | |||||
'456caf10e9535160d90e874b45aa426de762f19f'), | |||||
hashutil.hex_to_hash( | |||||
'745bab676c8f3cec8016e0c39ea61cf57e518865' | |||||
)] | |||||
self.storage.content_missing_per_sha1 = MagicMock(return_value=[]) | |||||
# when | |||||
actual_content = backend.content_missing_per_sha1(sha1s_bin) | |||||
# then | |||||
self.assertEquals(actual_content, []) | |||||
self.storage.content_missing_per_sha1.assert_called_with(sha1s_bin) | |||||
@istest | |||||
def content_missing_per_sha1_some(self): | |||||
# given | |||||
sha1s_bin = [hashutil.hex_to_hash( | |||||
'456caf10e9535160d90e874b45aa426de762f19f'), | |||||
hashutil.hex_to_hash( | |||||
'745bab676c8f3cec8016e0c39ea61cf57e518865' | |||||
)] | |||||
self.storage.content_missing_per_sha1 = MagicMock(return_value=[ | |||||
hashutil.hex_to_hash( | |||||
'745bab676c8f3cec8016e0c39ea61cf57e518865' | |||||
)]) | |||||
# when | |||||
actual_content = backend.content_missing_per_sha1(sha1s_bin) | |||||
# then | |||||
self.assertEquals(actual_content, [hashutil.hex_to_hash( | |||||
'745bab676c8f3cec8016e0c39ea61cf57e518865' | |||||
)]) | |||||
self.storage.content_missing_per_sha1.assert_called_with(sha1s_bin) | |||||
@istest | |||||
def origin_get(self): | def origin_get(self): | ||||
# given | # given | ||||
self.storage.origin_get = MagicMock(return_value={ | self.storage.origin_get = MagicMock(return_value={ | ||||
'id': 'origin-id', | 'id': 'origin-id', | ||||
'lister': 'uuid-lister', | 'lister': 'uuid-lister', | ||||
'project': 'uuid-project', | 'project': 'uuid-project', | ||||
'url': 'ftp://some/url/to/origin', | 'url': 'ftp://some/url/to/origin', | ||||
'type': 'ftp'}) | 'type': 'ftp'}) | ||||
▲ Show 20 Lines • Show All 338 Lines • Show Last 20 Lines |