core: run ruff format

This commit is contained in:
RhodeCode Admin 2025-01-13 17:47:37 +01:00
parent 7130effb58
commit 166db21812
821 changed files with 82905 additions and 84121 deletions

View file

@ -18,96 +18,111 @@
import pytest
from rhodecode.tests import HG_REPO
from rhodecode.api.tests.utils import (
build_data, api_call, assert_error, assert_ok)
from rhodecode.api.tests.utils import build_data, api_call, assert_error, assert_ok
@pytest.mark.usefixtures("testuser_api", "app")
class TestApiSearch(object):
@pytest.mark.parametrize("sort_dir", [
"asc",
"desc",
])
@pytest.mark.parametrize("sort", [
"xxx",
"author_email",
"date",
"message",
])
@pytest.mark.parametrize("query, expected_hits, expected_paths", [
('todo', 23, [
'vcs/backends/hg/inmemory.py',
'vcs/tests/test_git.py']),
('extension:rst installation', 6, [
'docs/index.rst',
'docs/installation.rst']),
('def repo', 87, [
'vcs/tests/test_git.py',
'vcs/tests/test_changesets.py']),
('repository:%s def test' % HG_REPO, 18, [
'vcs/tests/test_git.py',
'vcs/tests/test_changesets.py']),
('"def main"', 9, [
'vcs/__init__.py',
'vcs/tests/__init__.py',
'vcs/utils/progressbar.py']),
('owner:test_admin', 358, [
'vcs/tests/base.py',
'MANIFEST.in',
'vcs/utils/termcolors.py',
'docs/theme/ADC/static/documentation.png']),
('owner:test_admin def main', 72, [
'vcs/__init__.py',
'vcs/tests/test_utils_filesize.py',
'vcs/tests/test_cli.py']),
('owner:michał test', 0, []),
])
@pytest.mark.parametrize(
"sort_dir",
[
"asc",
"desc",
],
)
@pytest.mark.parametrize(
"sort",
[
"xxx",
"author_email",
"date",
"message",
],
)
@pytest.mark.parametrize(
"query, expected_hits, expected_paths",
[
("todo", 23, ["vcs/backends/hg/inmemory.py", "vcs/tests/test_git.py"]),
("extension:rst installation", 6, ["docs/index.rst", "docs/installation.rst"]),
("def repo", 87, ["vcs/tests/test_git.py", "vcs/tests/test_changesets.py"]),
("repository:%s def test" % HG_REPO, 18, ["vcs/tests/test_git.py", "vcs/tests/test_changesets.py"]),
('"def main"', 9, ["vcs/__init__.py", "vcs/tests/__init__.py", "vcs/utils/progressbar.py"]),
(
"owner:test_admin",
358,
[
"vcs/tests/base.py",
"MANIFEST.in",
"vcs/utils/termcolors.py",
"docs/theme/ADC/static/documentation.png",
],
),
(
"owner:test_admin def main",
72,
["vcs/__init__.py", "vcs/tests/test_utils_filesize.py", "vcs/tests/test_cli.py"],
),
("owner:michał test", 0, []),
],
)
def test_search_content_results(self, sort_dir, sort, query, expected_hits, expected_paths):
id_, params = build_data(
self.apikey_regular, 'search',
self.apikey_regular,
"search",
search_query=query,
search_sort='{}:{}'.format(sort_dir, sort),
search_type='content')
search_sort="{}:{}".format(sort_dir, sort),
search_type="content",
)
response = api_call(self.app, params)
json_response = response.json
assert json_response['result']['item_count'] == expected_hits
paths = [x['f_path'] for x in json_response['result']['results']]
assert json_response["result"]["item_count"] == expected_hits
paths = [x["f_path"] for x in json_response["result"]["results"]]
for expected_path in expected_paths:
assert expected_path in paths
@pytest.mark.parametrize("sort_dir", [
"asc",
"desc",
])
@pytest.mark.parametrize("sort", [
"xxx",
"date",
"file",
"size",
])
@pytest.mark.parametrize("query, expected_hits, expected_paths", [
('readme.rst', 3, []),
('test*', 75, []),
('*model*', 1, []),
('extension:rst', 48, []),
('extension:rst api', 24, []),
])
@pytest.mark.parametrize(
"sort_dir",
[
"asc",
"desc",
],
)
@pytest.mark.parametrize(
"sort",
[
"xxx",
"date",
"file",
"size",
],
)
@pytest.mark.parametrize(
"query, expected_hits, expected_paths",
[
("readme.rst", 3, []),
("test*", 75, []),
("*model*", 1, []),
("extension:rst", 48, []),
("extension:rst api", 24, []),
],
)
def test_search_file_paths(self, sort_dir, sort, query, expected_hits, expected_paths):
id_, params = build_data(
self.apikey_regular, 'search',
self.apikey_regular,
"search",
search_query=query,
search_sort='{}:{}'.format(sort_dir, sort),
search_type='path')
search_sort="{}:{}".format(sort_dir, sort),
search_type="path",
)
response = api_call(self.app, params)
json_response = response.json
assert json_response['result']['item_count'] == expected_hits
paths = [x['f_path'] for x in json_response['result']['results']]
assert json_response["result"]["item_count"] == expected_hits
paths = [x["f_path"] for x in json_response["result"]["results"]]
for expected_path in expected_paths:
assert expected_path in paths