Page MenuHomeSoftware Heritage

D338.id.diff
No OneTemporary

D338.id.diff

diff --git a/swh/web/tests/api/test_api_lookup.py b/swh/web/tests/api/test_api_lookup.py
--- a/swh/web/tests/api/test_api_lookup.py
+++ b/swh/web/tests/api/test_api_lookup.py
@@ -27,8 +27,8 @@
test_generic_lookup_fn, 'sha1', 'unused_arg',
notfound_msg='This will be raised because None is returned.')
- self.assertIn('This will be raised because None is returned.',
- cm.exception.args[0])
+ self.assertIn('This will be raised because None is returned.',
+ cm.exception.args[0])
@istest
def generic_api_map_are_enriched_and_transformed_to_list(self):
diff --git a/swh/web/tests/browse/test_utils.py b/swh/web/tests/browse/test_utils.py
--- a/swh/web/tests/browse/test_utils.py
+++ b/swh/web/tests/browse/test_utils.py
@@ -63,13 +63,14 @@
}]
mock_origin_visits.return_value = visits
+ visit_id = 12
with self.assertRaises(NotFoundExc) as cm:
- visit_id = 12
visit = utils.get_origin_visit(origin_info,
visit_id=visit_id)
- self.assertIn('Visit with id %s for origin with id %s not found' %
- (origin_info['id'], visit_id),
- cm.exception.args[0])
+ exception_text = cm.exception.args[0]
+ self.assertIn('Visit with id %s' % visit_id, exception_text)
+ self.assertIn('type %s' % origin_info['type'], exception_text)
+ self.assertIn('url %s' % origin_info['url'], exception_text)
visit = utils.get_origin_visit(origin_info, visit_id=2)
self.assertEqual(visit, visits[1])
diff --git a/swh/web/tests/common/test_query.py b/swh/web/tests/common/test_query.py
--- a/swh/web/tests/common/test_query.py
+++ b/swh/web/tests/common/test_query.py
@@ -88,7 +88,7 @@
'sha1:blah',
['sha1'],
'useless error message for this use case')
- self.assertIn('Error input', cm.exception.args[0])
+ self.assertIn('Error input', cm.exception.args[0])
mock_hash.assert_called_once_with('sha1:blah')
@@ -104,7 +104,7 @@
'sha1:431',
['sha1_git'],
'Only sha1_git!')
- self.assertIn('Only sha1_git!', cm.exception.args[0])
+ self.assertIn('Only sha1_git!', cm.exception.args[0])
mock_hash.assert_called_once_with('sha1:431')
@@ -138,5 +138,5 @@
# when
with self.assertRaises(BadInputExc) as cm:
query.parse_uuid4('7c33636b-8f11-4bda-89d9-ba8b76a42')
- self.assertIn('badly formed hexadecimal UUID string',
- cm.exception.args[0])
+ self.assertIn('badly formed hexadecimal UUID string',
+ cm.exception.args[0])
diff --git a/swh/web/tests/common/test_service.py b/swh/web/tests/common/test_service.py
--- a/swh/web/tests/common/test_service.py
+++ b/swh/web/tests/common/test_service.py
@@ -720,7 +720,7 @@
with self.assertRaises(BadInputExc) as cm:
# when
service.lookup_release('not-a-sha1')
- self.assertIn('invalid checksum', cm.exception.args[0])
+ self.assertIn('invalid checksum', cm.exception.args[0].lower())
mock_storage.release_get.called = False
@@ -735,7 +735,7 @@
service.lookup_release(
'13c1d34d138ec13b5ebad226dc2528dc7506c956e4646f62d4daf5'
'1aea892abe')
- self.assertIn('sha1_git supported', cm.exception.args[0])
+ self.assertEqual('Only sha1_git is supported.', cm.exception.args[0])
mock_storage.release_get.called = False
@@ -816,7 +816,7 @@
# when
with self.assertRaises(BadInputExc) as cm:
service.lookup_revision_with_context(sha1_git_root, sha1_git)
- self.assertIn('Only sha1_git is supported', cm.exception.args[0])
+ self.assertIn('Only sha1_git is supported', cm.exception.args[0])
@istest
def lookup_revision_with_context_ko_not_a_sha1_2(self):
@@ -828,7 +828,7 @@
# when
with self.assertRaises(BadInputExc) as cm:
service.lookup_revision_with_context(sha1_git_root, sha1_git)
- self.assertIn('Only sha1_git is supported', cm.exception.args[0])
+ self.assertIn('Only sha1_git is supported', cm.exception.args[0])
@patch('swh.web.common.service.storage')
@istest
@@ -846,8 +846,8 @@
# when
with self.assertRaises(NotFoundExc) as cm:
service.lookup_revision_with_context(sha1_git_root, sha1_git)
- self.assertIn('Revision 777777bdf3629f916219feb3dcc7393ded1bc8db'
- ' not found', cm.exception.args[0])
+ self.assertIn('Revision 777777bdf3629f916219feb3dcc7393ded1bc8db'
+ ' not found', cm.exception.args[0])
mock_storage.revision_get.assert_called_once_with(
[sha1_git_bin])
@@ -869,8 +869,8 @@
# when
with self.assertRaises(NotFoundExc) as cm:
service.lookup_revision_with_context(sha1_git_root, sha1_git)
- self.assertIn('Revision 65a55bbdf3629f916219feb3dcc7393ded1bc8db'
- ' not found', cm.exception.args[0])
+ self.assertIn('Revision root 65a55bbdf3629f916219feb3dcc7393ded1bc8db'
+ ' not found', cm.exception.args[0])
mock_storage.revision_get.assert_has_calls([call([sha1_git_bin]),
call([sha1_git_root_bin])])
@@ -1042,7 +1042,7 @@
# when
with self.assertRaises(NotFoundExc) as cm:
service.lookup_directory_with_revision('123')
- self.assertIn('Revision 123 not found', cm.exception.args[0])
+ self.assertIn('Revision 123 not found', cm.exception.args[0])
mock_query.parse_hash_with_algorithms_or_throws.assert_called_once_with
('123', ['sha1'], 'Only sha1_git is supported.')
@@ -1071,9 +1071,11 @@
service.lookup_directory_with_revision(
'123',
'path/to/something/unknown')
- self.assertIn("Directory/File 'path/to/something/unknown' " +
- "pointed to by revision 123 not found",
- cm.exception.args[0])
+ exception_text = cm.exception.args[0].lower()
+ self.assertIn('directory or file', exception_text)
+ self.assertIn('path/to/something/unknown', exception_text)
+ self.assertIn('revision 123', exception_text)
+ self.assertIn('not found', exception_text)
mock_query.parse_hash_with_algorithms_or_throws.assert_called_once_with
('123', ['sha1'], 'Only sha1_git is supported.')
@@ -1116,8 +1118,8 @@
service.lookup_directory_with_revision(
'123',
'some/path/to/rev')
- self.assertIn("Entity of type 'rev' not implemented.",
- cm.exception.args[0])
+ self.assertIn("Entity of type rev not implemented.",
+ cm.exception.args[0])
# then
mock_query.parse_hash_with_algorithms_or_throws.assert_called_once_with
@@ -1389,12 +1391,13 @@
service.lookup_revision_message(
self.SHA1_SAMPLE)
- # then
- mock_storage.revision_get.assert_called_with(
- self.SHA1_SAMPLE_BIN)
- self.assertEqual(cm.exception.args[0], 'No message for revision '
- 'with sha1_git '
- '18d8be353ed3480476f032475e7c233eff7371d5.')
+ # then
+ mock_storage.revision_get.assert_called_with(
+ [self.SHA1_SAMPLE_BIN])
+ self.assertEqual(
+ cm.exception.args[0],
+ 'No message for revision with sha1_git %s.' % self.SHA1_SAMPLE,
+ )
@patch('swh.web.common.service.storage')
@istest
@@ -1407,12 +1410,13 @@
service.lookup_revision_message(
self.SHA1_SAMPLE)
- # then
- mock_storage.revision_get.assert_called_with(
- self.SHA1_SAMPLE_BIN)
- self.assertEqual(cm.exception.args[0], 'Revision with sha1_git '
- '18d8be353ed3480476f032475e7c233eff7371d5 '
- 'not found.')
+ # then
+ mock_storage.revision_get.assert_called_with(
+ [self.SHA1_SAMPLE_BIN])
+ self.assertEqual(
+ cm.exception.args[0],
+ 'Revision with sha1_git %s not found.' % self.SHA1_SAMPLE,
+ )
@patch('swh.web.common.service.storage')
@istest
@@ -1574,9 +1578,9 @@
# when
with self.assertRaises(NotFoundExc) as cm:
service.lookup_content_raw('sha1:' + self.SHA1_SAMPLE)
- self.assertIn(cm.exc.args[0],
- 'Content with %s checksum equals to %s not found!' %
- ('sha1', self.SHA1_SAMPLE))
+ self.assertIn(cm.exception.args[0],
+ 'Content with %s checksum equals to %s not found!' %
+ ('sha1', self.SHA1_SAMPLE))
mock_storage.content_find.assert_called_with(
{'sha1': hash_to_bytes(self.SHA1_SAMPLE)})
@@ -1613,9 +1617,9 @@
with self.assertRaises(NotFoundExc) as cm:
# then
service.lookup_content('sha1:%s' % self.SHA1_SAMPLE)
- self.assertIn(cm.exc.args[0],
- 'Content with %s checksum equals to %s not found!' %
- ('sha1', self.SHA1_SAMPLE))
+ self.assertIn(cm.exception.args[0],
+ 'Content with %s checksum equals to %s not found!' %
+ ('sha1', self.SHA1_SAMPLE))
mock_storage.content_find.assert_called_with(
{'sha1': self.SHA1_SAMPLE_BIN})
@@ -1871,21 +1875,21 @@
mock_storage.revision_get_by.return_value = None
# when
+ origin_id = 1
+ branch_name = 'master3'
+ ts = None
with self.assertRaises(NotFoundExc) as cm:
- origin_id = 1
- branch_name = 'master3'
- ts = None
service.lookup_revision_with_context_by(origin_id, branch_name, ts,
'sha1')
- # then
- self.assertIn(
- 'Revision with (origin_id: %s, branch_name: %s'
- ', ts: %s) not found.' % (origin_id,
- branch_name,
- ts), cm.exception.args[0])
-
- mock_storage.revision_get_by.assert_called_once_with(
- origin_id, branch_name, ts)
+ # then
+ self.assertIn(
+ 'Revision with (origin_id: %s, branch_name: %s'
+ ', ts: %s) not found.' % (origin_id,
+ branch_name,
+ ts), cm.exception.args[0])
+
+ mock_storage.revision_get_by.assert_called_once_with(
+ origin_id, branch_name, limit=1, timestamp=ts)
@patch('swh.web.common.service.lookup_revision_with_context')
@patch('swh.web.common.service.storage')
diff --git a/swh/web/tests/common/test_utils.py b/swh/web/tests/common/test_utils.py
--- a/swh/web/tests/common/test_utils.py
+++ b/swh/web/tests/common/test_utils.py
@@ -152,8 +152,8 @@
with self.assertRaises(BadInputExc) as cm:
utils.get_swh_persistent_id('foo', sha1_git)
- self.assertIn('Invalid object type', cm.exception.args[0])
+ self.assertIn('Invalid object type', cm.exception.args[0])
with self.assertRaises(BadInputExc) as cm:
utils.get_swh_persistent_id(swh_object_type, 'not a valid id')
- self.assertIn('Invalid object id', cm.exception.args[0])
+ self.assertIn('Invalid object id', cm.exception.args[0])

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 30, 5:11 PM (3 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217748

Event Timeline