Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/tests/test_backend.py
Show First 20 Lines • Show All 450 Lines • ▼ Show 20 Lines | def revision_log(self): | ||||
# then | # then | ||||
self.assertEqual(list(actual_revision), stub_revision_log) | self.assertEqual(list(actual_revision), stub_revision_log) | ||||
self.storage.revision_log.assert_called_with([sha1_bin], 100) | self.storage.revision_log.assert_called_with([sha1_bin], 100) | ||||
@istest | @istest | ||||
def revision_log_by(self): | def revision_log_by(self): | ||||
# given | # given | ||||
# given | |||||
sha1_bin = hashutil.hex_to_hash( | sha1_bin = hashutil.hex_to_hash( | ||||
'28d8be353ed3480476f032475e7c233eff7371d5') | '28d8be353ed3480476f032475e7c233eff7371d5') | ||||
stub_revision_log = [{ | stub_revision_log = [{ | ||||
'id': sha1_bin, | 'id': sha1_bin, | ||||
'directory': hashutil.hex_to_hash( | 'directory': hashutil.hex_to_hash( | ||||
'7834ef7e7c357ce2af928115c6c6a42b7e2a44e6'), | '7834ef7e7c357ce2af928115c6c6a42b7e2a44e6'), | ||||
'author': { | 'author': { | ||||
'name': b'bill & boule', | 'name': b'bill & boule', | ||||
Show All 9 Lines | def revision_log_by(self): | ||||
'committer_date': datetime.datetime(2000, 1, 17, 11, 23, 54), | 'committer_date': datetime.datetime(2000, 1, 17, 11, 23, 54), | ||||
'committer_date_offset': 0, | 'committer_date_offset': 0, | ||||
'synthetic': False, | 'synthetic': False, | ||||
'type': 'git', | 'type': 'git', | ||||
'parents': [], | 'parents': [], | ||||
'metadata': [], | 'metadata': [], | ||||
}] | }] | ||||
self.storage.revision_get_by = MagicMock(return_value=[ | self.storage.revision_log_by = MagicMock( | ||||
{'id': sha1_bin}]) | return_value=stub_revision_log) | ||||
self.storage.revision_log = MagicMock(return_value=stub_revision_log) | |||||
# when | # when | ||||
actual_log = backend.revision_log_by(1, 'refs/heads/master', None) | actual_log = backend.revision_log_by(1, 'refs/heads/master', None) | ||||
# then | # then | ||||
self.assertEqual(actual_log, stub_revision_log) | self.assertEqual(actual_log, stub_revision_log) | ||||
self.storage.revision_log.assert_called_with([sha1_bin], 100) | self.storage.revision_log.assert_called_with([sha1_bin], 100) | ||||
@istest | @istest | ||||
def revision_log_by_norev(self): | def revision_log_by_norev(self): | ||||
# given | # given | ||||
# given | |||||
sha1_bin = hashutil.hex_to_hash( | sha1_bin = hashutil.hex_to_hash( | ||||
'28d8be353ed3480476f032475e7c233eff7371d5') | '28d8be353ed3480476f032475e7c233eff7371d5') | ||||
self.storage.revision_get_by = MagicMock(return_value=None) | self.storage.revision_log_by = MagicMock(return_value=None) | ||||
# when | # when | ||||
actual_log = backend.revision_log_by(1, 'refs/heads/master', None) | actual_log = backend.revision_log_by(1, 'refs/heads/master', None) | ||||
# then | # then | ||||
self.assertEqual(actual_log, None) | self.assertEqual(actual_log, None) | ||||
self.storage.revision_log.assert_called_with([sha1_bin], 100) | self.storage.revision_log.assert_called_with([sha1_bin], 100) | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |