Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_origin.py
Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | def test_api_origin_not_found(self, mock_service): | ||||
self.assertEqual(rv.status_code, 404) | self.assertEqual(rv.status_code, 404) | ||||
self.assertEqual(rv['Content-Type'], 'application/json') | self.assertEqual(rv['Content-Type'], 'application/json') | ||||
self.assertEqual(rv.data, { | self.assertEqual(rv.data, { | ||||
'exception': 'NotFoundExc', | 'exception': 'NotFoundExc', | ||||
'reason': 'Origin with id 4321 not found.' | 'reason': 'Origin with id 4321 not found.' | ||||
}) | }) | ||||
mock_service.lookup_origin.assert_called_with({'id': '4321'}) | mock_service.lookup_origin.assert_called_with({'id': '4321'}) | ||||
@patch('swh.web.common.service.idx_storage') | |||||
def test_api_origin_metadata_search(self, mock_idx_storage): | |||||
# given | |||||
mock_idx_storage.origin_intrinsic_metadata_search_fulltext \ | |||||
.return_value = [{ | |||||
'from_revision': | |||||
b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed \xf2U\xfa\x05B8', | |||||
'metadata': {'author': 'Jane Doe'}, | |||||
'origin_id': 54974445, | |||||
'tool': { | |||||
'configuration': { | |||||
'context': ['NpmMapping', 'CodemetaMapping'], | |||||
'type': 'local' | |||||
}, | |||||
'id': 3, | |||||
'name': 'swh-metadata-detector', | |||||
'version': '0.0.1' | |||||
} | |||||
}] | |||||
# when | |||||
rv = self.client.get( | |||||
'/api/1/origin/metadata-search/?fulltext=Jane%20Doe') | |||||
# then | |||||
self.assertEqual(rv.status_code, 200) | |||||
self.assertEqual(rv['Content-Type'], 'application/json') | |||||
self.assertEqual(rv.data, { | |||||
'origin_id': 54974445, | |||||
'metadata': {'author': 'Jane Doe'}, | |||||
'tool': { | |||||
'configuration': { | |||||
'context': ['NpmMapping', 'CodemetaMapping'], | |||||
'type': 'local' | |||||
}, | |||||
'from_revision': 'foo', | |||||
'id': 3, | |||||
'name': 'swh-metadata-detector', | |||||
'version': '0.0.1', | |||||
} | |||||
}) | |||||
mock_idx_storage.origin_intrinsic_metadata_search_fulltext \ | |||||
.assert_called_with({'conjunction': ['Jane Doe']}) | |||||
anlambert: You should not pass the `fulltext` parameter for that test to succed no ? | |||||
Done Inline Actionsindeed, thanks -_- vlorentz: indeed, thanks -_- |
You should not pass the fulltext parameter for that test to succed no ?