Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/api/views/test_origin.py
Show First 20 Lines • Show All 491 Lines • ▼ Show 20 Lines | def test_api_origin_search_words(api_client): | ||||
rv = api_client.get(url) | rv = api_client.get(url) | ||||
assert rv.status_code == 200, rv.data | assert rv.status_code == 200, rv.data | ||||
assert rv['Content-Type'] == 'application/json' | assert rv['Content-Type'] == 'application/json' | ||||
assert len(rv.data) == 1 | assert len(rv.data) == 1 | ||||
assert {origin['url'] for origin in rv.data} \ | assert {origin['url'] for origin in rv.data} \ | ||||
== {'https://github.com/memononen/libtess2'} | == {'https://github.com/memononen/libtess2'} | ||||
def test_api_origin_search_regexp(api_client): | |||||
expected_origins = { | |||||
'https://github.com/memononen/libtess2', | |||||
'repo_with_submodules' | |||||
} | |||||
url = reverse('api-1-origin-search', | |||||
url_args={'url_pattern': '(repo|libtess)'}, | |||||
query_params={'limit': 10, | |||||
'regexp': True}) | |||||
rv = api_client.get(url) | |||||
assert rv.status_code == 200, rv.data | |||||
assert rv['Content-Type'] == 'application/json' | |||||
assert {origin['url'] for origin in rv.data} == expected_origins | |||||
@pytest.mark.parametrize('limit', [1, 2, 3, 10]) | @pytest.mark.parametrize('limit', [1, 2, 3, 10]) | ||||
def test_api_origin_search_scroll(api_client, archive_data, limit): | def test_api_origin_search_scroll(api_client, archive_data, limit): | ||||
expected_origins = { | expected_origins = { | ||||
'https://github.com/wcoder/highlightjs-line-numbers.js', | 'https://github.com/wcoder/highlightjs-line-numbers.js', | ||||
'https://github.com/memononen/libtess2', | 'https://github.com/memononen/libtess2', | ||||
} | } | ||||
url = reverse('api-1-origin-search', | url = reverse('api-1-origin-search', | ||||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |