##// END OF EJS Templates
admin: fixed problems with generating last change in admin panels....
admin: fixed problems with generating last change in admin panels. - from now on also updated_on will refer as last commit change instead of last update of DB. Reason for that is since we have audit logs the last db update should be taken from there along the change info. Storing last commit date in the dedicated field makes it searchable, sortable and faster to read.

File last commit:

r3968:2ec277c2 default
r4000:52837660 default
Show More
test_fts_search.py
115 lines | 3.9 KiB | text/x-python | PythonLexer
api: added tests for the search API
r3607 # -*- coding: utf-8 -*-
# Copyright (C) 2010-2019 RhodeCode GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import pytest
from rhodecode.tests import HG_REPO
from rhodecode.api.tests.utils import (
build_data, api_call, assert_error, assert_ok)
@pytest.mark.usefixtures("testuser_api", "app")
class TestApiSearch(object):
dan
search: added per-backend sorting fields....
r3968 @pytest.mark.parametrize("sort_dir", [
"asc",
"desc",
])
@pytest.mark.parametrize("sort", [
"xxx",
"author_email",
"date",
"message",
])
api: added tests for the search API
r3607 @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, []),
])
dan
search: added per-backend sorting fields....
r3968 def test_search_content_results(self, sort_dir, sort, query, expected_hits, expected_paths):
api: added tests for the search API
r3607 id_, params = build_data(
self.apikey_regular, 'search',
search_query=query,
dan
search: added per-backend sorting fields....
r3968 search_sort='{}:{}'.format(sort_dir, sort),
api: added tests for the search API
r3607 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']]
for expected_path in expected_paths:
assert expected_path in paths
dan
search: added per-backend sorting fields....
r3968 @pytest.mark.parametrize("sort_dir", [
"asc",
"desc",
])
@pytest.mark.parametrize("sort", [
"xxx",
"date",
"file",
"size",
])
api: added tests for the search API
r3607 @pytest.mark.parametrize("query, expected_hits, expected_paths", [
('readme.rst', 3, []),
('test*', 75, []),
('*model*', 1, []),
('extension:rst', 48, []),
('extension:rst api', 24, []),
])
dan
search: added per-backend sorting fields....
r3968 def test_search_file_paths(self, sort_dir, sort, query, expected_hits, expected_paths):
api: added tests for the search API
r3607 id_, params = build_data(
self.apikey_regular, 'search',
search_query=query,
dan
search: added per-backend sorting fields....
r3968 search_sort='{}:{}'.format(sort_dir, sort),
api: added tests for the search API
r3607 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']]
for expected_path in expected_paths:
assert expected_path in paths