Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_origin.py
Show First 20 Lines • Show All 467 Lines • ▼ Show 20 Lines | def test_api_origin_search_scroll(self, limit): | ||||
url = reverse('api-1-origin-search', | url = reverse('api-1-origin-search', | ||||
url_args={'url_pattern': 'github.com'}, | url_args={'url_pattern': 'github.com'}, | ||||
query_params={'limit': limit}) | query_params={'limit': limit}) | ||||
results = self._scroll_results(url) | results = self._scroll_results(url) | ||||
self.assertEqual({origin['url'] for origin in results}, | self.assertEqual({origin['url'] for origin in results}, | ||||
expected_origins) | expected_origins) | ||||
anlambert: The test needs to be updated after the increase of limit bound to 1000. | |||||
def test_api_origin_search_limit(self): | |||||
self.storage.origin_add([ | |||||
{'url': 'http://foobar/{}'.format(i)} | |||||
for i in range(2000) | |||||
]) | |||||
url = reverse('api-1-origin-search', | |||||
url_args={'url_pattern': 'foobar'}, | |||||
query_params={'limit': 1050}) | |||||
rv = self.client.get(url) | |||||
self.assertEqual(rv.status_code, 200, rv.data) | |||||
self.assertEqual(rv['Content-Type'], 'application/json') | |||||
self.assertEqual(len(rv.data), 1000) | |||||
@given(origin()) | @given(origin()) | ||||
def test_api_origin_metadata_search(self, origin): | def test_api_origin_metadata_search(self, origin): | ||||
with patch('swh.web.common.service.idx_storage') as mock_idx_storage: | with patch('swh.web.common.service.idx_storage') as mock_idx_storage: | ||||
mock_idx_storage.origin_intrinsic_metadata_search_fulltext \ | mock_idx_storage.origin_intrinsic_metadata_search_fulltext \ | ||||
.side_effect = lambda conjunction, limit: [{ | .side_effect = lambda conjunction, limit: [{ | ||||
'from_revision': ( | 'from_revision': ( | ||||
b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed ' | b'p&\xb7\xc1\xa2\xafVR\x1e\x95\x1c\x01\xed ' | ||||
b'\xf2U\xfa\x05B8'), | b'\xf2U\xfa\x05B8'), | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |
The test needs to be updated after the increase of limit bound to 1000.