From e564ec9b32b3f91b0f671b10818133a56e4246e5 Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Tue, 18 Jul 2023 09:45:22 +0200 Subject: [PATCH] api: make all tests for API pass --- .../api/tests/test_comment_pull_request.py | 28 ++++++------------- rhodecode/api/tests/test_create_gist.py | 1 - .../api/tests/test_create_pull_request.py | 1 - rhodecode/api/tests/test_create_repo.py | 10 +++---- rhodecode/api/tests/test_create_repo_group.py | 1 - rhodecode/api/tests/test_create_user.py | 1 - rhodecode/api/tests/test_create_user_group.py | 1 - rhodecode/api/tests/test_delete_gist.py | 1 - rhodecode/api/tests/test_delete_repo.py | 1 - rhodecode/api/tests/test_delete_repo_group.py | 1 - rhodecode/api/tests/test_delete_user.py | 1 - rhodecode/api/tests/test_delete_user_group.py | 1 - rhodecode/api/tests/test_deprecated_api.py | 1 - rhodecode/api/tests/test_fork_repo.py | 1 - rhodecode/api/tests/test_fts_search.py | 1 - rhodecode/api/tests/test_get_gist.py | 6 ++-- rhodecode/api/tests/test_get_gists.py | 1 - rhodecode/api/tests/test_get_ip.py | 1 - rhodecode/api/tests/test_get_locks.py | 1 - rhodecode/api/tests/test_get_method.py | 3 +- rhodecode/api/tests/test_get_pull_request.py | 12 ++++---- .../tests/test_get_pull_request_comments.py | 4 --- rhodecode/api/tests/test_get_pull_requests.py | 1 - rhodecode/api/tests/test_get_repo.py | 1 - .../api/tests/test_get_repo_changeset.py | 5 ++-- rhodecode/api/tests/test_get_repo_comments.py | 1 - rhodecode/api/tests/test_get_repo_group.py | 1 - rhodecode/api/tests/test_get_repo_groups.py | 1 - rhodecode/api/tests/test_get_repo_nodes.py | 1 - rhodecode/api/tests/test_get_repo_refs.py | 1 - rhodecode/api/tests/test_get_repos.py | 1 - rhodecode/api/tests/test_get_server_info.py | 1 - rhodecode/api/tests/test_get_user.py | 1 - rhodecode/api/tests/test_get_user_group.py | 1 - rhodecode/api/tests/test_get_user_groups.py | 6 ++-- rhodecode/api/tests/test_get_users.py | 1 - .../tests/test_grant_user_group_permission.py | 1 - ...ant_user_group_permission_to_repo_group.py | 1 - ...ant_user_group_permission_to_user_group.py | 1 - .../api/tests/test_grant_user_permission.py | 1 - ...est_grant_user_permission_to_repo_group.py | 1 - ...est_grant_user_permission_to_user_group.py | 1 - rhodecode/api/tests/test_invalidate_cache.py | 1 - .../api/tests/test_merge_pull_request.py | 5 ++-- rhodecode/api/tests/test_pull.py | 1 - .../api/tests/test_remove_field_from_repo.py | 1 - .../tests/test_remove_user_from_user_group.py | 1 - rhodecode/api/tests/test_repo_locking.py | 1 - rhodecode/api/tests/test_rescan_repos.py | 1 - .../test_revoke_user_group_permission.py | 1 - ...e_user_group_permission_from_repo_group.py | 1 - ...e_user_group_permission_from_user_group.py | 1 - .../api/tests/test_revoke_user_permission.py | 1 - ..._revoke_user_permission_from_repo_group.py | 1 - ..._revoke_user_permission_from_user_group.py | 1 - rhodecode/api/tests/test_store_exception.py | 1 - .../api/tests/test_update_pull_request.py | 5 ++-- rhodecode/api/tests/test_update_repo.py | 1 - rhodecode/api/tests/test_update_repo_group.py | 1 - rhodecode/api/tests/test_update_user.py | 1 - rhodecode/api/tests/test_update_user_group.py | 1 - rhodecode/api/tests/test_utils.py | 10 ++++--- rhodecode/api/tests/utils.py | 3 +- rhodecode/api/views/search_api.py | 2 +- 64 files changed, 39 insertions(+), 111 deletions(-) diff --git a/rhodecode/api/tests/test_comment_pull_request.py b/rhodecode/api/tests/test_comment_pull_request.py index 81c76699..e55484ae 100644 --- a/rhodecode/api/tests/test_comment_pull_request.py +++ b/rhodecode/api/tests/test_comment_pull_request.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -129,26 +128,30 @@ class TestCommentPullRequest(object): assert_ok(id_, expected, response.body) @pytest.mark.backends("git", "hg") - def test_api_comment_pull_request_change_status_with_specific_commit_id( + def test_api_comment_pull_request_change_status_with_specific_commit_id_and_test_commit( self, pr_util, no_notifications): pull_request = pr_util.create_pull_request() pull_request_id = pull_request.pull_request_id latest_commit_id = 'test_commit' + # inject additional revision, to fail test the status change on # non-latest commit pull_request.revisions = pull_request.revisions + ['test_commit'] id_, params = build_data( self.apikey, 'comment_pull_request', + message='test-change-of-status-not-allowed', repoid=pull_request.target_repo.repo_name, pullrequestid=pull_request.pull_request_id, status='approved', commit_id=latest_commit_id) response = api_call(self.app, params) pull_request = PullRequestModel().get(pull_request_id) + comments = CommentsModel().get_comments( + pull_request.target_repo.repo_id, pull_request=pull_request) expected = { 'pull_request_id': pull_request.pull_request_id, - 'comment_id': None, + 'comment_id': comments[-1].comment_id, 'status': {'given': 'approved', 'was_changed': False} } assert_ok(id_, expected, response.body) @@ -230,19 +233,6 @@ class TestCommentPullRequest(object): expected = 'userid is not the same as your user' assert_error(id_, expected, given=response.body) - @pytest.mark.backends("git", "hg") - def test_api_comment_pull_request_non_admin_with_userid_error(self, pr_util): - pull_request = pr_util.create_pull_request() - id_, params = build_data( - self.apikey_regular, 'comment_pull_request', - repoid=pull_request.target_repo.repo_name, - pullrequestid=pull_request.pull_request_id, - userid=TEST_USER_ADMIN_LOGIN) - response = api_call(self.app, params) - - expected = 'userid is not the same as your user' - assert_error(id_, expected, given=response.body) - @pytest.mark.backends("git", "hg") def test_api_comment_pull_request_wrong_commit_id_error(self, pr_util): pull_request = pr_util.create_pull_request() @@ -288,7 +278,7 @@ class TestCommentPullRequest(object): assert message_after_edit == text_form_db @pytest.mark.backends("git", "hg") - def test_api_edit_comment_wrong_version(self, pr_util): + def test_api_edit_comment_wrong_version_mismatch(self, pr_util): pull_request = pr_util.create_pull_request() id_, params = build_data( @@ -302,7 +292,7 @@ class TestCommentPullRequest(object): message_after_edit = 'just message' id_, params = build_data( - self.apikey_regular, + self.apikey, 'edit_comment', comment_id=comment_id, message=message_after_edit, @@ -333,7 +323,7 @@ class TestCommentPullRequest(object): version=0, ) response = api_call(self.app, params) - expected = "comment ({}) can't be changed with empty string".format(comment_id, 1) + expected = f"comment ({comment_id}) can't be changed with empty string" assert_error(id_, expected, given=response.body) @pytest.mark.backends("git", "hg") diff --git a/rhodecode/api/tests/test_create_gist.py b/rhodecode/api/tests/test_create_gist.py index 9b487863..2c6acf7c 100644 --- a/rhodecode/api/tests/test_create_gist.py +++ b/rhodecode/api/tests/test_create_gist.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_create_pull_request.py b/rhodecode/api/tests/test_create_pull_request.py index 204a6fbc..44d35923 100644 --- a/rhodecode/api/tests/test_create_pull_request.py +++ b/rhodecode/api/tests/test_create_pull_request.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_create_repo.py b/rhodecode/api/tests/test_create_repo.py index 3aa88e46..fa1fff4f 100644 --- a/rhodecode/api/tests/test_create_repo.py +++ b/rhodecode/api/tests/test_create_repo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -18,12 +17,9 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ -import json - import mock import pytest -from rhodecode.lib.utils2 import safe_unicode from rhodecode.lib.vcs import settings from rhodecode.model.meta import Session from rhodecode.model.repo import RepoModel @@ -32,6 +28,8 @@ from rhodecode.tests import TEST_USER_ADMIN_LOGIN from rhodecode.api.tests.utils import ( build_data, api_call, assert_ok, assert_error, crash) from rhodecode.tests.fixture import Fixture +from rhodecode.lib.ext_json import json +from rhodecode.lib.str_utils import safe_str fixture = Fixture() @@ -66,7 +64,7 @@ class TestCreateRepo(object): expected = ret assert_ok(id_, expected, given=response.body) - repo = RepoModel().get_by_repo_name(safe_unicode(expected_name)) + repo = RepoModel().get_by_repo_name(safe_str(expected_name)) assert repo is not None id_, params = build_data(self.apikey, 'get_repo', repoid=expected_name) @@ -77,7 +75,7 @@ class TestCreateRepo(object): assert body['result']['enable_locking'] is False assert body['result']['enable_statistics'] is False - fixture.destroy_repo(safe_unicode(expected_name)) + fixture.destroy_repo(safe_str(expected_name)) def test_api_create_restricted_repo_type(self, backend): repo_name = 'api-repo-type-{0}'.format(backend.alias) diff --git a/rhodecode/api/tests/test_create_repo_group.py b/rhodecode/api/tests/test_create_repo_group.py index bb1ddfa8..58d2450d 100644 --- a/rhodecode/api/tests/test_create_repo_group.py +++ b/rhodecode/api/tests/test_create_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_create_user.py b/rhodecode/api/tests/test_create_user.py index a1e52af6..ce15633d 100644 --- a/rhodecode/api/tests/test_create_user.py +++ b/rhodecode/api/tests/test_create_user.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_create_user_group.py b/rhodecode/api/tests/test_create_user_group.py index 15292c77..4c5a56a8 100644 --- a/rhodecode/api/tests/test_create_user_group.py +++ b/rhodecode/api/tests/test_create_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_delete_gist.py b/rhodecode/api/tests/test_delete_gist.py index b15c35a5..e2538278 100644 --- a/rhodecode/api/tests/test_delete_gist.py +++ b/rhodecode/api/tests/test_delete_gist.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_delete_repo.py b/rhodecode/api/tests/test_delete_repo.py index 87120bfc..29ef2ff5 100644 --- a/rhodecode/api/tests/test_delete_repo.py +++ b/rhodecode/api/tests/test_delete_repo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_delete_repo_group.py b/rhodecode/api/tests/test_delete_repo_group.py index 6917ffb3..1fc20f21 100644 --- a/rhodecode/api/tests/test_delete_repo_group.py +++ b/rhodecode/api/tests/test_delete_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_delete_user.py b/rhodecode/api/tests/test_delete_user.py index daf47835..1e15d244 100644 --- a/rhodecode/api/tests/test_delete_user.py +++ b/rhodecode/api/tests/test_delete_user.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_delete_user_group.py b/rhodecode/api/tests/test_delete_user_group.py index 59b1cc80..d048a9d5 100644 --- a/rhodecode/api/tests/test_delete_user_group.py +++ b/rhodecode/api/tests/test_delete_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_deprecated_api.py b/rhodecode/api/tests/test_deprecated_api.py index 6de58c81..b4a01117 100644 --- a/rhodecode/api/tests/test_deprecated_api.py +++ b/rhodecode/api/tests/test_deprecated_api.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_fork_repo.py b/rhodecode/api/tests/test_fork_repo.py index 53cd3565..766fc471 100644 --- a/rhodecode/api/tests/test_fork_repo.py +++ b/rhodecode/api/tests/test_fork_repo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_fts_search.py b/rhodecode/api/tests/test_fts_search.py index 2716bee2..df7e57be 100644 --- a/rhodecode/api/tests/test_fts_search.py +++ b/rhodecode/api/tests/test_fts_search.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_gist.py b/rhodecode/api/tests/test_get_gist.py index bdad934d..26c765e1 100644 --- a/rhodecode/api/tests/test_get_gist.py +++ b/rhodecode/api/tests/test_get_gist.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -21,6 +20,7 @@ import pytest +from rhodecode.lib.str_utils import safe_bytes from rhodecode.model.db import Gist from rhodecode.api.tests.utils import ( build_data, api_call, assert_error, assert_ok) @@ -54,8 +54,8 @@ class TestApiGetGist(object): def test_api_get_gist_with_content(self, gist_util, http_host_only_stub): mapping = { - u'filename1.txt': {'content': u'hello world'}, - u'filename1ą.txt': {'content': u'hello worldę'} + b'filename1.txt': {'content': b'hello world'}, + safe_bytes('filename1ą.txt'): {'content': safe_bytes('hello worldę')} } gist = gist_util.create_gist(gist_mapping=mapping) gist_id = gist.gist_access_id diff --git a/rhodecode/api/tests/test_get_gists.py b/rhodecode/api/tests/test_get_gists.py index 7227d25b..b3324e78 100644 --- a/rhodecode/api/tests/test_get_gists.py +++ b/rhodecode/api/tests/test_get_gists.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_ip.py b/rhodecode/api/tests/test_get_ip.py index 1dc7b2e2..bacf2602 100644 --- a/rhodecode/api/tests/test_get_ip.py +++ b/rhodecode/api/tests/test_get_ip.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_locks.py b/rhodecode/api/tests/test_get_locks.py index 34f4bc10..bd60bbea 100644 --- a/rhodecode/api/tests/test_get_locks.py +++ b/rhodecode/api/tests/test_get_locks.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_method.py b/rhodecode/api/tests/test_get_method.py index 675cc679..8970bca6 100644 --- a/rhodecode/api/tests/test_get_method.py +++ b/rhodecode/api/tests/test_get_method.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -50,7 +49,7 @@ class TestGetMethod(object): expected = ['comment_commit', {'apiuser': '', - 'comment_type': "", + 'comment_type': "", 'commit_id': '', 'extra_recipients': '', 'message': '', diff --git a/rhodecode/api/tests/test_get_pull_request.py b/rhodecode/api/tests/test_get_pull_request.py index 554c35d4..e4cbded2 100644 --- a/rhodecode/api/tests/test_get_pull_request.py +++ b/rhodecode/api/tests/test_get_pull_request.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -25,7 +24,8 @@ import urlobject from rhodecode.api.tests.utils import ( build_data, api_call, assert_error, assert_ok) from rhodecode.lib import helpers as h -from rhodecode.lib.utils2 import safe_unicode +from rhodecode.lib.str_utils import safe_str + pytestmark = pytest.mark.backends("git", "hg") @@ -50,13 +50,13 @@ class TestGetPullRequest(object): repo_name=pull_request.target_repo.repo_name, pull_request_id=pull_request.pull_request_id)) - pr_url = safe_unicode( + pr_url = safe_str( url_obj.with_netloc(http_host_only_stub)) - source_url = safe_unicode( + source_url = safe_str( pull_request.source_repo.clone_url().with_netloc(http_host_only_stub)) - target_url = safe_unicode( + target_url = safe_str( pull_request.target_repo.clone_url().with_netloc(http_host_only_stub)) - shadow_url = safe_unicode( + shadow_url = safe_str( PullRequestModel().get_shadow_clone_url(pull_request)) expected = { diff --git a/rhodecode/api/tests/test_get_pull_request_comments.py b/rhodecode/api/tests/test_get_pull_request_comments.py index 1085c4bf..fbccfbb8 100644 --- a/rhodecode/api/tests/test_get_pull_request_comments.py +++ b/rhodecode/api/tests/test_get_pull_request_comments.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -20,12 +19,9 @@ import pytest -import urlobject from rhodecode.api.tests.utils import ( build_data, api_call, assert_error, assert_ok) -from rhodecode.lib import helpers as h -from rhodecode.lib.utils2 import safe_unicode pytestmark = pytest.mark.backends("git", "hg") diff --git a/rhodecode/api/tests/test_get_pull_requests.py b/rhodecode/api/tests/test_get_pull_requests.py index d9ce336c..162170fc 100644 --- a/rhodecode/api/tests/test_get_pull_requests.py +++ b/rhodecode/api/tests/test_get_pull_requests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_repo.py b/rhodecode/api/tests/test_get_repo.py index eb084111..8737d1d3 100644 --- a/rhodecode/api/tests/test_get_repo.py +++ b/rhodecode/api/tests/test_get_repo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_repo_changeset.py b/rhodecode/api/tests/test_get_repo_changeset.py index 6729f121..8e0f66d6 100644 --- a/rhodecode/api/tests/test_get_repo_changeset.py +++ b/rhodecode/api/tests/test_get_repo_changeset.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -54,7 +53,7 @@ class TestGetRepoChangeset(object): details=details, ) response = api_call(self.app, params) - expected = "commit_id must be a string value got instead" + expected = "commit_id must be a string value got instead" assert_error(id_, expected, given=response.body) @pytest.mark.parametrize("details", ['basic', 'extended', 'full']) @@ -137,5 +136,5 @@ class TestGetRepoChangeset(object): details=details, ) response = api_call(self.app, params) - expected = "commit_id must be a string value got instead" + expected = "commit_id must be a string value got instead" assert_error(id_, expected, given=response.body) diff --git a/rhodecode/api/tests/test_get_repo_comments.py b/rhodecode/api/tests/test_get_repo_comments.py index 764fff6a..3e9b60dd 100644 --- a/rhodecode/api/tests/test_get_repo_comments.py +++ b/rhodecode/api/tests/test_get_repo_comments.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_repo_group.py b/rhodecode/api/tests/test_get_repo_group.py index 60e2b863..ff84a700 100644 --- a/rhodecode/api/tests/test_get_repo_group.py +++ b/rhodecode/api/tests/test_get_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_repo_groups.py b/rhodecode/api/tests/test_get_repo_groups.py index 6825a30f..999ef0c2 100644 --- a/rhodecode/api/tests/test_get_repo_groups.py +++ b/rhodecode/api/tests/test_get_repo_groups.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_repo_nodes.py b/rhodecode/api/tests/test_get_repo_nodes.py index 13bdca14..76dd9a95 100644 --- a/rhodecode/api/tests/test_get_repo_nodes.py +++ b/rhodecode/api/tests/test_get_repo_nodes.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_repo_refs.py b/rhodecode/api/tests/test_get_repo_refs.py index a81dd5a1..8bee7684 100644 --- a/rhodecode/api/tests/test_get_repo_refs.py +++ b/rhodecode/api/tests/test_get_repo_refs.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_repos.py b/rhodecode/api/tests/test_get_repos.py index 02f1c115..32b9fd8f 100644 --- a/rhodecode/api/tests/test_get_repos.py +++ b/rhodecode/api/tests/test_get_repos.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_server_info.py b/rhodecode/api/tests/test_get_server_info.py index fc6beaa4..4a10d3e2 100644 --- a/rhodecode/api/tests/test_get_server_info.py +++ b/rhodecode/api/tests/test_get_server_info.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_user.py b/rhodecode/api/tests/test_get_user.py index e9c11262..dc75dbe4 100644 --- a/rhodecode/api/tests/test_get_user.py +++ b/rhodecode/api/tests/test_get_user.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_user_group.py b/rhodecode/api/tests/test_get_user_group.py index 0bd095db..db043712 100644 --- a/rhodecode/api/tests/test_get_user_group.py +++ b/rhodecode/api/tests/test_get_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_get_user_groups.py b/rhodecode/api/tests/test_get_user_groups.py index 5325e0cb..18fe4453 100644 --- a/rhodecode/api/tests/test_get_user_groups.py +++ b/rhodecode/api/tests/test_get_user_groups.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -19,12 +18,11 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ -import json - import pytest from rhodecode.model.user import UserModel from rhodecode.api.tests.utils import build_data, api_call +from rhodecode.lib.ext_json import json @pytest.mark.usefixtures("testuser_api", "app") @@ -68,4 +66,4 @@ class TestGetUserGroups(object): result = json.loads(response.body) assert result['id'] == id_ assert result['error'] is None - assert sorted(result['result']) == sorted(expected_list) + assert result['result'] == expected_list diff --git a/rhodecode/api/tests/test_get_users.py b/rhodecode/api/tests/test_get_users.py index b10b8a57..79edd292 100644 --- a/rhodecode/api/tests/test_get_users.py +++ b/rhodecode/api/tests/test_get_users.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_grant_user_group_permission.py b/rhodecode/api/tests/test_grant_user_group_permission.py index 460acdca..39436136 100644 --- a/rhodecode/api/tests/test_grant_user_group_permission.py +++ b/rhodecode/api/tests/test_grant_user_group_permission.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_grant_user_group_permission_to_repo_group.py b/rhodecode/api/tests/test_grant_user_group_permission_to_repo_group.py index fbdc7913..9756a526 100644 --- a/rhodecode/api/tests/test_grant_user_group_permission_to_repo_group.py +++ b/rhodecode/api/tests/test_grant_user_group_permission_to_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_grant_user_group_permission_to_user_group.py b/rhodecode/api/tests/test_grant_user_group_permission_to_user_group.py index 0b952e2d..c48724a0 100644 --- a/rhodecode/api/tests/test_grant_user_group_permission_to_user_group.py +++ b/rhodecode/api/tests/test_grant_user_group_permission_to_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_grant_user_permission.py b/rhodecode/api/tests/test_grant_user_permission.py index 31c9e58d..027916b9 100644 --- a/rhodecode/api/tests/test_grant_user_permission.py +++ b/rhodecode/api/tests/test_grant_user_permission.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_grant_user_permission_to_repo_group.py b/rhodecode/api/tests/test_grant_user_permission_to_repo_group.py index 27f81bb4..49570511 100644 --- a/rhodecode/api/tests/test_grant_user_permission_to_repo_group.py +++ b/rhodecode/api/tests/test_grant_user_permission_to_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_grant_user_permission_to_user_group.py b/rhodecode/api/tests/test_grant_user_permission_to_user_group.py index a8f42c8f..f477a3ac 100644 --- a/rhodecode/api/tests/test_grant_user_permission_to_user_group.py +++ b/rhodecode/api/tests/test_grant_user_permission_to_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_invalidate_cache.py b/rhodecode/api/tests/test_invalidate_cache.py index 5b4b2300..926c636d 100644 --- a/rhodecode/api/tests/test_invalidate_cache.py +++ b/rhodecode/api/tests/test_invalidate_cache.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_merge_pull_request.py b/rhodecode/api/tests/test_merge_pull_request.py index 777c7645..5f2e9354 100644 --- a/rhodecode/api/tests/test_merge_pull_request.py +++ b/rhodecode/api/tests/test_merge_pull_request.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -112,7 +111,7 @@ class TestMergePullRequest(object): 'merge_status_message': 'This pull request can be automatically merged.', 'possible': True, 'merge_commit_id': pull_request.shadow_merge_ref.commit_id, - 'merge_ref': pull_request.shadow_merge_ref._asdict() + 'merge_ref': pull_request.shadow_merge_ref.asdict() } assert_ok(id_, expected, response.body) @@ -213,7 +212,7 @@ class TestMergePullRequest(object): 'merge_status_message': 'This pull request can be automatically merged.', 'possible': True, 'merge_commit_id': pull_request.shadow_merge_ref.commit_id, - 'merge_ref': pull_request.shadow_merge_ref._asdict() + 'merge_ref': pull_request.shadow_merge_ref.asdict() } assert_ok(id_, expected, response.body) diff --git a/rhodecode/api/tests/test_pull.py b/rhodecode/api/tests/test_pull.py index 8120d44e..68df27ae 100644 --- a/rhodecode/api/tests/test_pull.py +++ b/rhodecode/api/tests/test_pull.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_remove_field_from_repo.py b/rhodecode/api/tests/test_remove_field_from_repo.py index f033b880..548ab990 100644 --- a/rhodecode/api/tests/test_remove_field_from_repo.py +++ b/rhodecode/api/tests/test_remove_field_from_repo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_remove_user_from_user_group.py b/rhodecode/api/tests/test_remove_user_from_user_group.py index 35dd391a..ca04a328 100644 --- a/rhodecode/api/tests/test_remove_user_from_user_group.py +++ b/rhodecode/api/tests/test_remove_user_from_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_repo_locking.py b/rhodecode/api/tests/test_repo_locking.py index e4d932f9..b2423ff2 100644 --- a/rhodecode/api/tests/test_repo_locking.py +++ b/rhodecode/api/tests/test_repo_locking.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_rescan_repos.py b/rhodecode/api/tests/test_rescan_repos.py index 21d5666b..81dd01b7 100644 --- a/rhodecode/api/tests/test_rescan_repos.py +++ b/rhodecode/api/tests/test_rescan_repos.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_revoke_user_group_permission.py b/rhodecode/api/tests/test_revoke_user_group_permission.py index 8ff6699b..ed3f2f86 100644 --- a/rhodecode/api/tests/test_revoke_user_group_permission.py +++ b/rhodecode/api/tests/test_revoke_user_group_permission.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_revoke_user_group_permission_from_repo_group.py b/rhodecode/api/tests/test_revoke_user_group_permission_from_repo_group.py index 4f0fbab1..4f838916 100644 --- a/rhodecode/api/tests/test_revoke_user_group_permission_from_repo_group.py +++ b/rhodecode/api/tests/test_revoke_user_group_permission_from_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_revoke_user_group_permission_from_user_group.py b/rhodecode/api/tests/test_revoke_user_group_permission_from_user_group.py index 0ce71a28..4a1d5f67 100644 --- a/rhodecode/api/tests/test_revoke_user_group_permission_from_user_group.py +++ b/rhodecode/api/tests/test_revoke_user_group_permission_from_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_revoke_user_permission.py b/rhodecode/api/tests/test_revoke_user_permission.py index 93fb7ea4..6532a3bf 100644 --- a/rhodecode/api/tests/test_revoke_user_permission.py +++ b/rhodecode/api/tests/test_revoke_user_permission.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_revoke_user_permission_from_repo_group.py b/rhodecode/api/tests/test_revoke_user_permission_from_repo_group.py index 2906f287..3260aada 100644 --- a/rhodecode/api/tests/test_revoke_user_permission_from_repo_group.py +++ b/rhodecode/api/tests/test_revoke_user_permission_from_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_revoke_user_permission_from_user_group.py b/rhodecode/api/tests/test_revoke_user_permission_from_user_group.py index 5d515775..2c23ed06 100644 --- a/rhodecode/api/tests/test_revoke_user_permission_from_user_group.py +++ b/rhodecode/api/tests/test_revoke_user_permission_from_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_store_exception.py b/rhodecode/api/tests/test_store_exception.py index 3b2556aa..3f17dc49 100644 --- a/rhodecode/api/tests/test_store_exception.py +++ b/rhodecode/api/tests/test_store_exception.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_update_pull_request.py b/rhodecode/api/tests/test_update_pull_request.py index 05664b59..27f3576e 100644 --- a/rhodecode/api/tests/test_update_pull_request.py +++ b/rhodecode/api/tests/test_update_pull_request.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -82,8 +81,8 @@ class TestUpdatePullRequest(object): def test_api_update_update_commits(self, pr_util, no_notifications): commits = [ {'message': 'a'}, - {'message': 'b', 'added': [FileNode('file_b', 'test_content\n')]}, - {'message': 'c', 'added': [FileNode('file_c', 'test_content\n')]}, + {'message': 'b', 'added': [FileNode(b'file_b', b'test_content\n')]}, + {'message': 'c', 'added': [FileNode(b'file_c', b'test_content\n')]}, ] pull_request = pr_util.create_pull_request( commits=commits, target_head='a', source_head='b', revisions=['b']) diff --git a/rhodecode/api/tests/test_update_repo.py b/rhodecode/api/tests/test_update_repo.py index 3ad415cc..ba16857a 100644 --- a/rhodecode/api/tests/test_update_repo.py +++ b/rhodecode/api/tests/test_update_repo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_update_repo_group.py b/rhodecode/api/tests/test_update_repo_group.py index 41abc06f..05bef998 100644 --- a/rhodecode/api/tests/test_update_repo_group.py +++ b/rhodecode/api/tests/test_update_repo_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_update_user.py b/rhodecode/api/tests/test_update_user.py index ba8f2bc6..4e5b59f4 100644 --- a/rhodecode/api/tests/test_update_user.py +++ b/rhodecode/api/tests/test_update_user.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_update_user_group.py b/rhodecode/api/tests/test_update_user_group.py index b696c803..03abf70f 100644 --- a/rhodecode/api/tests/test_update_user_group.py +++ b/rhodecode/api/tests/test_update_user_group.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # diff --git a/rhodecode/api/tests/test_utils.py b/rhodecode/api/tests/test_utils.py index e9ac3e54..02c6c378 100644 --- a/rhodecode/api/tests/test_utils.py +++ b/rhodecode/api/tests/test_utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -28,7 +27,8 @@ from rhodecode.lib.vcs.exceptions import RepositoryError class TestGetCommitOrError(object): - def setup(self): + + def setup_method(self): self.commit_hash = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa10' @pytest.mark.parametrize("ref", ['ref', '12345', 'a:b:c:d', 'branch:name']) @@ -66,7 +66,8 @@ class TestGetCommitOrError(object): class TestResolveRefOrError(object): - def setup(self): + + def setup_method(self): self.commit_hash = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa10' def test_success_with_no_hash_specified(self): @@ -128,7 +129,8 @@ class TestResolveRefOrError(object): class TestGetRefHash(object): - def setup(self): + + def setup_method(self): self.commit_hash = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa10' self.bookmark_name = 'test-bookmark' diff --git a/rhodecode/api/tests/utils.py b/rhodecode/api/tests/utils.py index c005b7e1..cb291007 100644 --- a/rhodecode/api/tests/utils.py +++ b/rhodecode/api/tests/utils.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2010-2020 RhodeCode GmbH # @@ -50,7 +49,7 @@ def assert_ok(id_, expected, given): given = json.loads(given) if given.get('error'): err = given['error'] - pytest.fail(u"Unexpected ERROR in success response: {}".format(err)) + pytest.fail(f"Unexpected ERROR in expected success response: `{err}`") expected = jsonify({ 'id': id_, diff --git a/rhodecode/api/views/search_api.py b/rhodecode/api/views/search_api.py index afa4839e..d47b0e03 100644 --- a/rhodecode/api/views/search_api.py +++ b/rhodecode/api/views/search_api.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # Copyright (C) 2011-2020 RhodeCode GmbH #