##// END OF EJS Templates
search: add support for elastic search 6...
search: add support for elastic search 6 - elasticsearch new query lang and searcher - much more advanced query lang - added context aware search in repository groups, repository, commits, files view - optimized quick search bar speed when using full text search - added option to increase hits per file number from query URL using max_lines - search results can be now marked inside a text file using ?mark=HIGHLIGHT_TEXT added to the url

File last commit:

r2487:fcee5614 default
r3319:b8fd1d7a default
Show More
test_simplegit.py
139 lines | 5.7 KiB | text/x-python | PythonLexer
project: added all source files and assets
r1 # -*- coding: utf-8 -*-
release: update copyright year to 2018
r2487 # Copyright (C) 2010-2018 RhodeCode GmbH
project: added all source files and assets
r1 #
# 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
import urlparse
git-lfs: settings for GIT repos to enable git-lfs and set store location...
r1570 import mock
import simplejson as json
project: added all source files and assets
r1
git-lfs: settings for GIT repos to enable git-lfs and set store location...
r1570 from rhodecode.lib.vcs.backends.base import Config
project: added all source files and assets
r1 from rhodecode.tests.lib.middleware import mock_scm_app
import rhodecode.lib.middleware.simplegit as simplegit
git-lfs: added tests for git-lfs protocol detection...
r1567 def get_environ(url, request_method):
project: added all source files and assets
r1 """Construct a minimum WSGI environ based on the URL."""
parsed_url = urlparse.urlparse(url)
environ = {
'PATH_INFO': parsed_url.path,
'QUERY_STRING': parsed_url.query,
git-lfs: added tests for git-lfs protocol detection...
r1567 'REQUEST_METHOD': request_method,
project: added all source files and assets
r1 }
return environ
@pytest.mark.parametrize(
git-lfs: added tests for git-lfs protocol detection...
r1567 'url, expected_action, request_method',
project: added all source files and assets
r1 [
git-lfs: added tests for git-lfs protocol detection...
r1567 ('/foo/bar/info/refs?service=git-upload-pack', 'pull', 'GET'),
('/foo/bar/info/refs?service=git-receive-pack', 'push', 'GET'),
('/foo/bar/git-upload-pack', 'pull', 'GET'),
('/foo/bar/git-receive-pack', 'push', 'GET'),
project: added all source files and assets
r1 # Edge case: missing data for info/refs
git-lfs: added tests for git-lfs protocol detection...
r1567 ('/foo/info/refs?service=', 'pull', 'GET'),
('/foo/info/refs', 'pull', 'GET'),
project: added all source files and assets
r1 # Edge case: git command comes with service argument
git-lfs: added tests for git-lfs protocol detection...
r1567 ('/foo/git-upload-pack?service=git-receive-pack', 'pull', 'GET'),
('/foo/git-receive-pack?service=git-upload-pack', 'push', 'GET'),
project: added all source files and assets
r1 # Edge case: repo name conflicts with git commands
git-lfs: added tests for git-lfs protocol detection...
r1567 ('/git-receive-pack/git-upload-pack', 'pull', 'GET'),
('/git-receive-pack/git-receive-pack', 'push', 'GET'),
('/git-upload-pack/git-upload-pack', 'pull', 'GET'),
('/git-upload-pack/git-receive-pack', 'push', 'GET'),
('/foo/git-receive-pack', 'push', 'GET'),
project: added all source files and assets
r1 # Edge case: not a smart protocol url
git-lfs: added tests for git-lfs protocol detection...
r1567 ('/foo/bar', 'pull', 'GET'),
# GIT LFS cases, batch
('/foo/bar/info/lfs/objects/batch', 'push', 'GET'),
('/foo/bar/info/lfs/objects/batch', 'pull', 'POST'),
# GIT LFS oid, dl/upl
('/foo/bar/info/lfs/abcdeabcde', 'pull', 'GET'),
('/foo/bar/info/lfs/abcdeabcde', 'push', 'PUT'),
('/foo/bar/info/lfs/abcdeabcde', 'push', 'POST'),
# Edge case: repo name conflicts with git commands
('/info/lfs/info/lfs/objects/batch', 'push', 'GET'),
('/info/lfs/info/lfs/objects/batch', 'pull', 'POST'),
project: added all source files and assets
r1 ])
pylons: remove pylons as dependency...
r2351 def test_get_action(url, expected_action, request_method, baseapp, request_stub):
pylons: fixed code and test suite after removal of pylons.
r2358 app = simplegit.SimpleGit(config={'auth_ret_code': '', 'base_path': ''},
vcs: reduce sql queries used during pull/push operations.
r2140 registry=request_stub.registry)
git-lfs: added tests for git-lfs protocol detection...
r1567 assert expected_action == app._get_action(get_environ(url, request_method))
project: added all source files and assets
r1
@pytest.mark.parametrize(
git-lfs: added tests for git-lfs protocol detection...
r1567 'url, expected_repo_name, request_method',
project: added all source files and assets
r1 [
git-lfs: added tests for git-lfs protocol detection...
r1567 ('/foo/info/refs?service=git-upload-pack', 'foo', 'GET'),
('/foo/bar/info/refs?service=git-receive-pack', 'foo/bar', 'GET'),
('/foo/git-upload-pack', 'foo', 'GET'),
('/foo/git-receive-pack', 'foo', 'GET'),
('/foo/bar/git-upload-pack', 'foo/bar', 'GET'),
('/foo/bar/git-receive-pack', 'foo/bar', 'GET'),
# GIT LFS cases, batch
('/foo/bar/info/lfs/objects/batch', 'foo/bar', 'GET'),
('/example-git/info/lfs/objects/batch', 'example-git', 'POST'),
# GIT LFS oid, dl/upl
('/foo/info/lfs/abcdeabcde', 'foo', 'GET'),
('/foo/bar/info/lfs/abcdeabcde', 'foo/bar', 'PUT'),
('/my-git-repo/info/lfs/abcdeabcde', 'my-git-repo', 'POST'),
# Edge case: repo name conflicts with git commands
('/info/lfs/info/lfs/objects/batch', 'info/lfs', 'GET'),
('/info/lfs/info/lfs/objects/batch', 'info/lfs', 'POST'),
project: added all source files and assets
r1 ])
pylons: remove pylons as dependency...
r2351 def test_get_repository_name(url, expected_repo_name, request_method, baseapp, request_stub):
pylons: fixed code and test suite after removal of pylons.
r2358 app = simplegit.SimpleGit(config={'auth_ret_code': '', 'base_path': ''},
vcs: reduce sql queries used during pull/push operations.
r2140 registry=request_stub.registry)
git-lfs: added tests for git-lfs protocol detection...
r1567 assert expected_repo_name == app._get_repository_name(
get_environ(url, request_method))
project: added all source files and assets
r1
pylons: remove pylons as dependency...
r2351 def test_get_config(user_util, baseapp, request_stub):
git-lfs: settings for GIT repos to enable git-lfs and set store location...
r1570 repo = user_util.create_repo(repo_type='git')
pylons: fixed code and test suite after removal of pylons.
r2358 app = simplegit.SimpleGit(config={'auth_ret_code': '', 'base_path': ''},
vcs: reduce sql queries used during pull/push operations.
r2140 registry=request_stub.registry)
project: added all source files and assets
r1 extras = {'foo': 'FOO', 'bar': 'BAR'}
# We copy the extras as the method below will change the contents.
git-lfs: settings for GIT repos to enable git-lfs and set store location...
r1570 git_config = app._create_config(dict(extras), repo_name=repo.repo_name)
project: added all source files and assets
r1 expected_config = dict(extras)
expected_config.update({
'git_update_server_info': False,
git-lfs: settings for GIT repos to enable git-lfs and set store location...
r1570 'git_lfs_enabled': False,
'git_lfs_store_path': git_config['git_lfs_store_path']
project: added all source files and assets
r1 })
git-lfs: settings for GIT repos to enable git-lfs and set store location...
r1570 assert git_config == expected_config
project: added all source files and assets
r1
pylons: remove pylons as dependency...
r2351 def test_create_wsgi_app_uses_scm_app_from_simplevcs(baseapp, request_stub):
project: added all source files and assets
r1 config = {
'auth_ret_code': '',
'base_path': '',
'vcs.scm_app_implementation':
'rhodecode.tests.lib.middleware.mock_scm_app',
}
pylons: fixed code and test suite after removal of pylons.
r2358 app = simplegit.SimpleGit(config=config, registry=request_stub.registry)
project: added all source files and assets
r1 wsgi_app = app._create_wsgi_app('/tmp/test', 'test_repo', {})
assert wsgi_app is mock_scm_app.mock_git_wsgi