core: run ruff format
This commit is contained in:
parent
7130effb58
commit
166db21812
821 changed files with 82905 additions and 84121 deletions
|
|
@ -19,8 +19,7 @@
|
|||
import pytest
|
||||
|
||||
from rhodecode.model.db import ChangesetStatus, User
|
||||
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")
|
||||
|
|
@ -28,59 +27,74 @@ class TestCommentCommit(object):
|
|||
def test_api_comment_commit_on_empty_repo(self, backend):
|
||||
repo = backend.create_repo()
|
||||
id_, params = build_data(
|
||||
self.apikey, 'comment_commit', repoid=repo.repo_name,
|
||||
commit_id='tip', message='message', status_change=None)
|
||||
self.apikey, "comment_commit", repoid=repo.repo_name, commit_id="tip", message="message", status_change=None
|
||||
)
|
||||
response = api_call(self.app, params)
|
||||
expected = 'There are no commits yet'
|
||||
expected = "There are no commits yet"
|
||||
assert_error(id_, expected, given=response.body)
|
||||
|
||||
@pytest.mark.parametrize("commit_id, expected_err", [
|
||||
('abcabca', {'hg': 'Commit {commit} does not exist for `{repo}`',
|
||||
'git': 'Commit {commit} does not exist for `{repo}`',
|
||||
'svn': 'Commit id {commit} not understood.'}),
|
||||
('idontexist', {'hg': 'Commit {commit} does not exist for `{repo}`',
|
||||
'git': 'Commit {commit} does not exist for `{repo}`',
|
||||
'svn': 'Commit id {commit} not understood.'}),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"commit_id, expected_err",
|
||||
[
|
||||
(
|
||||
"abcabca",
|
||||
{
|
||||
"hg": "Commit {commit} does not exist for `{repo}`",
|
||||
"git": "Commit {commit} does not exist for `{repo}`",
|
||||
"svn": "Commit id {commit} not understood.",
|
||||
},
|
||||
),
|
||||
(
|
||||
"idontexist",
|
||||
{
|
||||
"hg": "Commit {commit} does not exist for `{repo}`",
|
||||
"git": "Commit {commit} does not exist for `{repo}`",
|
||||
"svn": "Commit id {commit} not understood.",
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_api_comment_commit_wrong_hash(self, backend, commit_id, expected_err):
|
||||
repo_name = backend.repo.repo_name
|
||||
id_, params = build_data(
|
||||
self.apikey, 'comment_commit', repoid=repo_name,
|
||||
commit_id=commit_id, message='message', status_change=None)
|
||||
self.apikey, "comment_commit", repoid=repo_name, commit_id=commit_id, message="message", status_change=None
|
||||
)
|
||||
response = api_call(self.app, params)
|
||||
|
||||
expected_err = expected_err[backend.alias]
|
||||
expected_err = expected_err.format(
|
||||
repo=backend.repo.scm_instance().name, commit=commit_id)
|
||||
expected_err = expected_err.format(repo=backend.repo.scm_instance().name, commit=commit_id)
|
||||
assert_error(id_, expected_err, given=response.body)
|
||||
|
||||
@pytest.mark.parametrize("status_change, message, commit_id", [
|
||||
(None, 'Hallo', 'tip'),
|
||||
(ChangesetStatus.STATUS_APPROVED, 'Approved', 'tip'),
|
||||
(ChangesetStatus.STATUS_REJECTED, 'Rejected', 'tip'),
|
||||
])
|
||||
def test_api_comment_commit(
|
||||
self, backend, status_change, message, commit_id,
|
||||
no_notifications):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"status_change, message, commit_id",
|
||||
[
|
||||
(None, "Hallo", "tip"),
|
||||
(ChangesetStatus.STATUS_APPROVED, "Approved", "tip"),
|
||||
(ChangesetStatus.STATUS_REJECTED, "Rejected", "tip"),
|
||||
],
|
||||
)
|
||||
def test_api_comment_commit(self, backend, status_change, message, commit_id, no_notifications):
|
||||
commit_id = backend.repo.scm_instance().get_commit(commit_id).raw_id
|
||||
|
||||
id_, params = build_data(
|
||||
self.apikey, 'comment_commit', repoid=backend.repo_name,
|
||||
commit_id=commit_id, message=message, status=status_change)
|
||||
self.apikey,
|
||||
"comment_commit",
|
||||
repoid=backend.repo_name,
|
||||
commit_id=commit_id,
|
||||
message=message,
|
||||
status=status_change,
|
||||
)
|
||||
response = api_call(self.app, params)
|
||||
repo = backend.repo.scm_instance()
|
||||
expected = {
|
||||
'msg': 'Commented on commit `%s` for repository `%s`' % (
|
||||
repo.get_commit().raw_id, backend.repo_name),
|
||||
'status_change': status_change,
|
||||
'success': True
|
||||
"msg": "Commented on commit `%s` for repository `%s`" % (repo.get_commit().raw_id, backend.repo_name),
|
||||
"status_change": status_change,
|
||||
"success": True,
|
||||
}
|
||||
assert_ok(id_, expected, given=response.body)
|
||||
|
||||
def test_api_comment_commit_with_extra_recipients(self, backend, user_util):
|
||||
|
||||
commit_id = backend.repo.scm_instance().get_commit('tip').raw_id
|
||||
commit_id = backend.repo.scm_instance().get_commit("tip").raw_id
|
||||
|
||||
user1 = user_util.create_user()
|
||||
user1_id = user1.user_id
|
||||
|
|
@ -88,27 +102,29 @@ class TestCommentCommit(object):
|
|||
user2_id = user2.user_id
|
||||
|
||||
id_, params = build_data(
|
||||
self.apikey, 'comment_commit', repoid=backend.repo_name,
|
||||
self.apikey,
|
||||
"comment_commit",
|
||||
repoid=backend.repo_name,
|
||||
commit_id=commit_id,
|
||||
message='abracadabra',
|
||||
extra_recipients=[user1.user_id, user2.username])
|
||||
message="abracadabra",
|
||||
extra_recipients=[user1.user_id, user2.username],
|
||||
)
|
||||
|
||||
response = api_call(self.app, params)
|
||||
repo = backend.repo.scm_instance()
|
||||
|
||||
expected = {
|
||||
'msg': 'Commented on commit `%s` for repository `%s`' % (
|
||||
repo.get_commit().raw_id, backend.repo_name),
|
||||
'status_change': None,
|
||||
'success': True
|
||||
"msg": "Commented on commit `%s` for repository `%s`" % (repo.get_commit().raw_id, backend.repo_name),
|
||||
"status_change": None,
|
||||
"success": True,
|
||||
}
|
||||
|
||||
assert_ok(id_, expected, given=response.body)
|
||||
# check user1/user2 inbox for notification
|
||||
user1 = User.get(user1_id)
|
||||
assert 1 == len(user1.notifications)
|
||||
assert 'abracadabra' in user1.notifications[0].notification.body
|
||||
assert "abracadabra" in user1.notifications[0].notification.body
|
||||
|
||||
user2 = User.get(user2_id)
|
||||
assert 1 == len(user2.notifications)
|
||||
assert 'abracadabra' in user2.notifications[0].notification.body
|
||||
assert "abracadabra" in user2.notifications[0].notification.body
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue