##// END OF EJS Templates
fix(users-creation): fixed reported error for emails as dict not label
fix(users-creation): fixed reported error for emails as dict not label

File last commit:

r5173:95a4b30f default
r5451:2003323d default
Show More
test_get_user_group_data.py
102 lines | 4.0 KiB | text/x-python | PythonLexer
/ rhodecode / apps / home / tests / test_get_user_group_data.py
copyrights: updated for 2023
r5088 # Copyright (C) 2016-2023 RhodeCode GmbH
core: moved users and user groups autocomplete into pyramid....
r1666 #
# 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/
tests: fixed all tests for python3 BIG changes
r5087
copyrights: updated for 2023
r5088 # Copyright (C) 2016-2023 RhodeCode GmbH
tests: fixed all tests for python3 BIG changes
r5087 #
# 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/
core: moved users and user groups autocomplete into pyramid....
r1666
import pytest
tests: refactor code to use a single test url generator
r5173 from rhodecode.lib.ext_json import json
core: moved users and user groups autocomplete into pyramid....
r1666 from rhodecode.tests import TestController
from rhodecode.tests.fixture import Fixture
tests: refactor code to use a single test url generator
r5173 from rhodecode.tests.routes import route_path
core: moved users and user groups autocomplete into pyramid....
r1666
fixture = Fixture()
class TestUserGroupAutocompleteData(TestController):
def test_returns_list_of_user_groups(self, user_util, xhr_header):
self.log_user()
user_group = user_util.create_user_group(active=True)
user_group_name = user_group.users_group_name
response = self.app.get(
route_path('user_group_autocomplete_data'),
extra_environ=xhr_header, status=200)
result = json.loads(response.body)
values = [suggestion['value'] for suggestion in result['suggestions']]
assert user_group_name in values
def test_returns_inactive_user_groups_when_active_flag_sent(
self, user_util, xhr_header):
self.log_user()
user_group = user_util.create_user_group(active=False)
user_group_name = user_group.users_group_name
response = self.app.get(
route_path('user_group_autocomplete_data',
params=dict(active='0')),
extra_environ=xhr_header, status=200)
result = json.loads(response.body)
values = [suggestion['value'] for suggestion in result['suggestions']]
assert user_group_name in values
response = self.app.get(
route_path('user_group_autocomplete_data',
params=dict(active='1')),
extra_environ=xhr_header, status=200)
result = json.loads(response.body)
values = [suggestion['value'] for suggestion in result['suggestions']]
assert user_group_name not in values
@pytest.mark.parametrize('query, count', [
('hello1', 0),
('dev', 1),
])
def test_result_is_limited_when_query_is_sent(self, user_util, xhr_header, query, count):
self.log_user()
user_util._test_name = 'dev-test'
user_util.create_user_group()
response = self.app.get(
route_path('user_group_autocomplete_data',
params=dict(user_groups='true',
query=query)),
extra_environ=xhr_header, status=200)
result = json.loads(response.body)
assert len(result['suggestions']) == count