##// END OF EJS Templates
comments: renamed ChangesetCommentsModel to CommentsModel to reflect what it actually does....
marcink -
r1323:41333240 default
parent child Browse files
Show More
@@ -20,7 +20,7 b''
20
20
21 import pytest
21 import pytest
22
22
23 from rhodecode.model.comment import ChangesetCommentsModel
23 from rhodecode.model.comment import CommentsModel
24 from rhodecode.model.db import UserLog
24 from rhodecode.model.db import UserLog
25 from rhodecode.model.pull_request import PullRequestModel
25 from rhodecode.model.pull_request import PullRequestModel
26 from rhodecode.tests import TEST_USER_ADMIN_LOGIN
26 from rhodecode.tests import TEST_USER_ADMIN_LOGIN
@@ -52,7 +52,7 b' class TestCommentPullRequest(object):'
52 response = api_call(self.app, params)
52 response = api_call(self.app, params)
53 pull_request = PullRequestModel().get(pull_request.pull_request_id)
53 pull_request = PullRequestModel().get(pull_request.pull_request_id)
54
54
55 comments = ChangesetCommentsModel().get_comments(
55 comments = CommentsModel().get_comments(
56 pull_request.target_repo.repo_id, pull_request=pull_request)
56 pull_request.target_repo.repo_id, pull_request=pull_request)
57
57
58 expected = {
58 expected = {
@@ -83,7 +83,7 b' class TestCommentPullRequest(object):'
83 response = api_call(self.app, params)
83 response = api_call(self.app, params)
84 pull_request = PullRequestModel().get(pull_request_id)
84 pull_request = PullRequestModel().get(pull_request_id)
85
85
86 comments = ChangesetCommentsModel().get_comments(
86 comments = CommentsModel().get_comments(
87 pull_request.target_repo.repo_id, pull_request=pull_request)
87 pull_request.target_repo.repo_id, pull_request=pull_request)
88 expected = {
88 expected = {
89 'pull_request_id': pull_request.pull_request_id,
89 'pull_request_id': pull_request.pull_request_id,
@@ -132,7 +132,7 b' class TestCommentPullRequest(object):'
132 response = api_call(self.app, params)
132 response = api_call(self.app, params)
133 pull_request = PullRequestModel().get(pull_request_id)
133 pull_request = PullRequestModel().get(pull_request_id)
134
134
135 comments = ChangesetCommentsModel().get_comments(
135 comments = CommentsModel().get_comments(
136 pull_request.target_repo.repo_id, pull_request=pull_request)
136 pull_request.target_repo.repo_id, pull_request=pull_request)
137 expected = {
137 expected = {
138 'pull_request_id': pull_request.pull_request_id,
138 'pull_request_id': pull_request.pull_request_id,
@@ -30,7 +30,7 b' from rhodecode.lib.auth import (HasRepoP'
30 from rhodecode.lib.base import vcs_operation_context
30 from rhodecode.lib.base import vcs_operation_context
31 from rhodecode.lib.utils2 import str2bool
31 from rhodecode.lib.utils2 import str2bool
32 from rhodecode.model.changeset_status import ChangesetStatusModel
32 from rhodecode.model.changeset_status import ChangesetStatusModel
33 from rhodecode.model.comment import ChangesetCommentsModel
33 from rhodecode.model.comment import CommentsModel
34 from rhodecode.model.db import Session, ChangesetStatus
34 from rhodecode.model.db import Session, ChangesetStatus
35 from rhodecode.model.pull_request import PullRequestModel
35 from rhodecode.model.pull_request import PullRequestModel
36 from rhodecode.model.settings import SettingsModel
36 from rhodecode.model.settings import SettingsModel
@@ -455,7 +455,7 b' def comment_pull_request(request, apiuse'
455 renderer = rc_config.get('rhodecode_markup_renderer', 'rst')
455 renderer = rc_config.get('rhodecode_markup_renderer', 'rst')
456
456
457 status_change = status and allowed_to_change_status
457 status_change = status and allowed_to_change_status
458 comment = ChangesetCommentsModel().create(
458 comment = CommentsModel().create(
459 text=text,
459 text=text,
460 repo=pull_request.target_repo.repo_id,
460 repo=pull_request.target_repo.repo_id,
461 user=apiuser.user_id,
461 user=apiuser.user_id,
@@ -34,7 +34,7 b' from rhodecode.lib.exceptions import Sta'
34 from rhodecode.lib.utils2 import str2bool, time_to_datetime
34 from rhodecode.lib.utils2 import str2bool, time_to_datetime
35 from rhodecode.lib.ext_json import json
35 from rhodecode.lib.ext_json import json
36 from rhodecode.model.changeset_status import ChangesetStatusModel
36 from rhodecode.model.changeset_status import ChangesetStatusModel
37 from rhodecode.model.comment import ChangesetCommentsModel
37 from rhodecode.model.comment import CommentsModel
38 from rhodecode.model.db import (
38 from rhodecode.model.db import (
39 Session, ChangesetStatus, RepositoryField, Repository, RepoGroup)
39 Session, ChangesetStatus, RepositoryField, Repository, RepoGroup)
40 from rhodecode.model.repo import RepoModel
40 from rhodecode.model.repo import RepoModel
@@ -1436,7 +1436,7 b' def comment_commit('
1436 rc_config = SettingsModel().get_all_settings()
1436 rc_config = SettingsModel().get_all_settings()
1437 renderer = rc_config.get('rhodecode_markup_renderer', 'rst')
1437 renderer = rc_config.get('rhodecode_markup_renderer', 'rst')
1438 status_change_label = ChangesetStatus.get_status_lbl(status)
1438 status_change_label = ChangesetStatus.get_status_lbl(status)
1439 comm = ChangesetCommentsModel().create(
1439 comm = CommentsModel().create(
1440 message, repo, user, commit_id=commit_id,
1440 message, repo, user, commit_id=commit_id,
1441 status_change=status_change_label,
1441 status_change=status_change_label,
1442 status_change_type=status,
1442 status_change_type=status,
@@ -57,7 +57,7 b' from rhodecode.model.repo import RepoMod'
57 from rhodecode.model.auth_token import AuthTokenModel
57 from rhodecode.model.auth_token import AuthTokenModel
58 from rhodecode.model.meta import Session
58 from rhodecode.model.meta import Session
59 from rhodecode.model.pull_request import PullRequestModel
59 from rhodecode.model.pull_request import PullRequestModel
60 from rhodecode.model.comment import ChangesetCommentsModel
60 from rhodecode.model.comment import CommentsModel
61
61
62 log = logging.getLogger(__name__)
62 log = logging.getLogger(__name__)
63
63
@@ -322,7 +322,7 b' class MyAccountController(BaseController'
322 data = []
322 data = []
323 for pr in pull_requests:
323 for pr in pull_requests:
324 repo_id = pr.target_repo_id
324 repo_id = pr.target_repo_id
325 comments = ChangesetCommentsModel().get_all_comments(
325 comments = CommentsModel().get_all_comments(
326 repo_id, pull_request=pr)
326 repo_id, pull_request=pr)
327 owned = pr.user_id == c.rhodecode_user.user_id
327 owned = pr.user_id == c.rhodecode_user.user_id
328 status = pr.calculated_review_status()
328 status = pr.calculated_review_status()
@@ -46,7 +46,7 b' from rhodecode.lib.vcs.exceptions import'
46 RepositoryError, CommitDoesNotExistError, NodeDoesNotExistError)
46 RepositoryError, CommitDoesNotExistError, NodeDoesNotExistError)
47 from rhodecode.model.db import ChangesetComment, ChangesetStatus
47 from rhodecode.model.db import ChangesetComment, ChangesetStatus
48 from rhodecode.model.changeset_status import ChangesetStatusModel
48 from rhodecode.model.changeset_status import ChangesetStatusModel
49 from rhodecode.model.comment import ChangesetCommentsModel
49 from rhodecode.model.comment import CommentsModel
50 from rhodecode.model.meta import Session
50 from rhodecode.model.meta import Session
51 from rhodecode.model.repo import RepoModel
51 from rhodecode.model.repo import RepoModel
52
52
@@ -210,7 +210,7 b' class ChangesetController(BaseRepoContro'
210 c.comments = []
210 c.comments = []
211 if len(c.commit_ranges) == 1:
211 if len(c.commit_ranges) == 1:
212 commit = c.commit_ranges[0]
212 commit = c.commit_ranges[0]
213 c.comments = ChangesetCommentsModel().get_comments(
213 c.comments = CommentsModel().get_comments(
214 c.rhodecode_db_repo.repo_id,
214 c.rhodecode_db_repo.repo_id,
215 revision=commit.raw_id)
215 revision=commit.raw_id)
216 c.statuses.append(ChangesetStatusModel().get_status(
216 c.statuses.append(ChangesetStatusModel().get_status(
@@ -255,9 +255,9 b' class ChangesetController(BaseRepoContro'
255 return None
255 return None
256 return get_node
256 return get_node
257
257
258 inline_comments = ChangesetCommentsModel().get_inline_comments(
258 inline_comments = CommentsModel().get_inline_comments(
259 c.rhodecode_db_repo.repo_id, revision=commit.raw_id)
259 c.rhodecode_db_repo.repo_id, revision=commit.raw_id)
260 c.inline_cnt = ChangesetCommentsModel().get_inline_comments_count(
260 c.inline_cnt = CommentsModel().get_inline_comments_count(
261 inline_comments)
261 inline_comments)
262
262
263 diffset = codeblocks.DiffSet(
263 diffset = codeblocks.DiffSet(
@@ -346,7 +346,7 b' class ChangesetController(BaseRepoContro'
346 commit_ids = multi_commit_ids or [commit_id]
346 commit_ids = multi_commit_ids or [commit_id]
347 comment = None
347 comment = None
348 for current_id in filter(None, commit_ids):
348 for current_id in filter(None, commit_ids):
349 c.co = comment = ChangesetCommentsModel().create(
349 c.co = comment = CommentsModel().create(
350 text=text,
350 text=text,
351 repo=c.rhodecode_db_repo.repo_id,
351 repo=c.rhodecode_db_repo.repo_id,
352 user=c.rhodecode_user.user_id,
352 user=c.rhodecode_user.user_id,
@@ -426,7 +426,7 b' class ChangesetController(BaseRepoContro'
426 owner = (comment.author.user_id == c.rhodecode_user.user_id)
426 owner = (comment.author.user_id == c.rhodecode_user.user_id)
427 is_repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
427 is_repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
428 if h.HasPermissionAny('hg.admin')() or is_repo_admin or owner:
428 if h.HasPermissionAny('hg.admin')() or is_repo_admin or owner:
429 ChangesetCommentsModel().delete(comment=comment)
429 CommentsModel().delete(comment=comment)
430 Session().commit()
430 Session().commit()
431 return True
431 return True
432 else:
432 else:
@@ -55,7 +55,7 b' from rhodecode.lib.vcs.exceptions import'
55 NodeDoesNotExistError)
55 NodeDoesNotExistError)
56
56
57 from rhodecode.model.changeset_status import ChangesetStatusModel
57 from rhodecode.model.changeset_status import ChangesetStatusModel
58 from rhodecode.model.comment import ChangesetCommentsModel
58 from rhodecode.model.comment import CommentsModel
59 from rhodecode.model.db import (PullRequest, ChangesetStatus, ChangesetComment,
59 from rhodecode.model.db import (PullRequest, ChangesetStatus, ChangesetComment,
60 Repository, PullRequestVersion)
60 Repository, PullRequestVersion)
61 from rhodecode.model.forms import PullRequestForm
61 from rhodecode.model.forms import PullRequestForm
@@ -258,7 +258,7 b' class PullrequestsController(BaseRepoCon'
258 _render = PartialRenderer('data_table/_dt_elements.mako')
258 _render = PartialRenderer('data_table/_dt_elements.mako')
259 data = []
259 data = []
260 for pr in pull_requests:
260 for pr in pull_requests:
261 comments = ChangesetCommentsModel().get_all_comments(
261 comments = CommentsModel().get_all_comments(
262 c.rhodecode_db_repo.repo_id, pull_request=pr)
262 c.rhodecode_db_repo.repo_id, pull_request=pr)
263
263
264 data.append({
264 data.append({
@@ -796,7 +796,7 b' class PullrequestsController(BaseRepoCon'
796 pull_request_latest, c.rhodecode_user) and not pr_closed
796 pull_request_latest, c.rhodecode_user) and not pr_closed
797 c.allowed_to_comment = not pr_closed
797 c.allowed_to_comment = not pr_closed
798
798
799 cc_model = ChangesetCommentsModel()
799 cc_model = CommentsModel()
800
800
801 c.pull_request_reviewers = pull_request_at_ver.reviewers_statuses()
801 c.pull_request_reviewers = pull_request_at_ver.reviewers_statuses()
802 c.pull_request_review_status = pull_request_at_ver.calculated_review_status()
802 c.pull_request_review_status = pull_request_at_ver.calculated_review_status()
@@ -837,7 +837,7 b' class PullrequestsController(BaseRepoCon'
837
837
838 # outdated comments
838 # outdated comments
839 c.outdated_cnt = 0
839 c.outdated_cnt = 0
840 if ChangesetCommentsModel.use_outdated_comments(pull_request_latest):
840 if CommentsModel.use_outdated_comments(pull_request_latest):
841 outdated_comments = cc_model.get_outdated_comments(
841 outdated_comments = cc_model.get_outdated_comments(
842 c.rhodecode_db_repo.repo_id,
842 c.rhodecode_db_repo.repo_id,
843 pull_request=pull_request_at_ver)
843 pull_request=pull_request_at_ver)
@@ -923,7 +923,7 b' class PullrequestsController(BaseRepoCon'
923 if close_pr:
923 if close_pr:
924 message = _('Closing with') + ' ' + message
924 message = _('Closing with') + ' ' + message
925 text = text or message
925 text = text or message
926 comm = ChangesetCommentsModel().create(
926 comm = CommentsModel().create(
927 text=text,
927 text=text,
928 repo=c.rhodecode_db_repo.repo_id,
928 repo=c.rhodecode_db_repo.repo_id,
929 user=c.rhodecode_user.user_id,
929 user=c.rhodecode_user.user_id,
@@ -1013,7 +1013,7 b' class PullrequestsController(BaseRepoCon'
1013 is_repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
1013 is_repo_admin = h.HasRepoPermissionAny('repository.admin')(c.repo_name)
1014 if h.HasPermissionAny('hg.admin')() or is_repo_admin or is_owner:
1014 if h.HasPermissionAny('hg.admin')() or is_repo_admin or is_owner:
1015 old_calculated_status = co.pull_request.calculated_review_status()
1015 old_calculated_status = co.pull_request.calculated_review_status()
1016 ChangesetCommentsModel().delete(comment=co)
1016 CommentsModel().delete(comment=co)
1017 Session().commit()
1017 Session().commit()
1018 calculated_status = co.pull_request.calculated_review_status()
1018 calculated_status = co.pull_request.calculated_review_status()
1019 if old_calculated_status != calculated_status:
1019 if old_calculated_status != calculated_status:
@@ -114,7 +114,7 b' class PullRequestCommentEvent(PullReques'
114 self.comment = comment
114 self.comment = comment
115
115
116 def as_dict(self):
116 def as_dict(self):
117 from rhodecode.model.comment import ChangesetCommentsModel
117 from rhodecode.model.comment import CommentsModel
118 data = super(PullRequestCommentEvent, self).as_dict()
118 data = super(PullRequestCommentEvent, self).as_dict()
119
119
120 status = None
120 status = None
@@ -125,7 +125,7 b' class PullRequestCommentEvent(PullReques'
125 'comment': {
125 'comment': {
126 'status': status,
126 'status': status,
127 'text': self.comment.text,
127 'text': self.comment.text,
128 'url': ChangesetCommentsModel().get_url(self.comment)
128 'url': CommentsModel().get_url(self.comment)
129 }
129 }
130 })
130 })
131 return data
131 return data
@@ -201,8 +201,8 b' class ChangesetStatusModel(BaseModel):'
201 return new_status
201 return new_status
202
202
203 if not comment:
203 if not comment:
204 from rhodecode.model.comment import ChangesetCommentsModel
204 from rhodecode.model.comment import CommentsModel
205 comment = ChangesetCommentsModel().create(
205 comment = CommentsModel().create(
206 text=self._render_auto_status_message(
206 text=self._render_auto_status_message(
207 status, commit_id=revision, pull_request=pull_request),
207 status, commit_id=revision, pull_request=pull_request),
208 repo=repo,
208 repo=repo,
@@ -48,7 +48,7 b' from rhodecode.model.notification import'
48 log = logging.getLogger(__name__)
48 log = logging.getLogger(__name__)
49
49
50
50
51 class ChangesetCommentsModel(BaseModel):
51 class CommentsModel(BaseModel):
52
52
53 cls = ChangesetComment
53 cls = ChangesetComment
54
54
@@ -392,7 +392,7 b' class ChangesetCommentsModel(BaseModel):'
392
392
393 elif pull_request:
393 elif pull_request:
394 pull_request = self.__get_pull_request(pull_request)
394 pull_request = self.__get_pull_request(pull_request)
395 if not ChangesetCommentsModel.use_outdated_comments(pull_request):
395 if not CommentsModel.use_outdated_comments(pull_request):
396 q = self._visible_inline_comments_of_pull_request(pull_request)
396 q = self._visible_inline_comments_of_pull_request(pull_request)
397 else:
397 else:
398 q = self._all_inline_comments_of_pull_request(pull_request)
398 q = self._all_inline_comments_of_pull_request(pull_request)
@@ -414,7 +414,7 b' class ChangesetCommentsModel(BaseModel):'
414 return max(cls.DIFF_CONTEXT_BEFORE, cls.DIFF_CONTEXT_AFTER)
414 return max(cls.DIFF_CONTEXT_BEFORE, cls.DIFF_CONTEXT_AFTER)
415
415
416 def outdate_comments(self, pull_request, old_diff_data, new_diff_data):
416 def outdate_comments(self, pull_request, old_diff_data, new_diff_data):
417 if not ChangesetCommentsModel.use_outdated_comments(pull_request):
417 if not CommentsModel.use_outdated_comments(pull_request):
418 return
418 return
419
419
420 comments = self._visible_inline_comments_of_pull_request(pull_request)
420 comments = self._visible_inline_comments_of_pull_request(pull_request)
@@ -47,7 +47,7 b' from rhodecode.lib.vcs.exceptions import'
47 CommitDoesNotExistError, EmptyRepositoryError)
47 CommitDoesNotExistError, EmptyRepositoryError)
48 from rhodecode.model import BaseModel
48 from rhodecode.model import BaseModel
49 from rhodecode.model.changeset_status import ChangesetStatusModel
49 from rhodecode.model.changeset_status import ChangesetStatusModel
50 from rhodecode.model.comment import ChangesetCommentsModel
50 from rhodecode.model.comment import CommentsModel
51 from rhodecode.model.db import (
51 from rhodecode.model.db import (
52 PullRequest, PullRequestReviewers, ChangesetStatus,
52 PullRequest, PullRequestReviewers, ChangesetStatus,
53 PullRequestVersion, ChangesetComment)
53 PullRequestVersion, ChangesetComment)
@@ -552,7 +552,7 b' class PullRequestModel(BaseModel):'
552 pull_request.merge_rev = merge_state.merge_ref.commit_id
552 pull_request.merge_rev = merge_state.merge_ref.commit_id
553 pull_request.updated_on = datetime.datetime.now()
553 pull_request.updated_on = datetime.datetime.now()
554
554
555 ChangesetCommentsModel().create(
555 CommentsModel().create(
556 text=unicode(_('Pull request merged and closed')),
556 text=unicode(_('Pull request merged and closed')),
557 repo=pull_request.target_repo.repo_id,
557 repo=pull_request.target_repo.repo_id,
558 user=user.user_id,
558 user=user.user_id,
@@ -655,7 +655,7 b' class PullRequestModel(BaseModel):'
655 old_diff_data, new_diff_data = self._generate_update_diffs(
655 old_diff_data, new_diff_data = self._generate_update_diffs(
656 pull_request, pull_request_version)
656 pull_request, pull_request_version)
657
657
658 ChangesetCommentsModel().outdate_comments(
658 CommentsModel().outdate_comments(
659 pull_request, old_diff_data=old_diff_data,
659 pull_request, old_diff_data=old_diff_data,
660 new_diff_data=new_diff_data)
660 new_diff_data=new_diff_data)
661
661
@@ -663,7 +663,7 b' class PullRequestModel(BaseModel):'
663 old_diff_data, new_diff_data)
663 old_diff_data, new_diff_data)
664
664
665 # Add an automatic comment to the pull request
665 # Add an automatic comment to the pull request
666 update_comment = ChangesetCommentsModel().create(
666 update_comment = CommentsModel().create(
667 text=self._render_update_message(changes, file_changes),
667 text=self._render_update_message(changes, file_changes),
668 repo=pull_request.target_repo,
668 repo=pull_request.target_repo,
669 user=pull_request.author,
669 user=pull_request.author,
@@ -730,7 +730,7 b' class PullRequestModel(BaseModel):'
730 def _generate_update_diffs(self, pull_request, pull_request_version):
730 def _generate_update_diffs(self, pull_request, pull_request_version):
731 diff_context = (
731 diff_context = (
732 self.DIFF_CONTEXT +
732 self.DIFF_CONTEXT +
733 ChangesetCommentsModel.needed_extra_diff_context())
733 CommentsModel.needed_extra_diff_context())
734 old_diff = self._get_diff_from_pr_or_version(
734 old_diff = self._get_diff_from_pr_or_version(
735 pull_request_version, context=diff_context)
735 pull_request_version, context=diff_context)
736 new_diff = self._get_diff_from_pr_or_version(
736 new_diff = self._get_diff_from_pr_or_version(
@@ -1001,7 +1001,7 b' class PullRequestModel(BaseModel):'
1001
1001
1002 internal_message = _('Closing with') + ' ' + message
1002 internal_message = _('Closing with') + ' ' + message
1003
1003
1004 comm = ChangesetCommentsModel().create(
1004 comm = CommentsModel().create(
1005 text=internal_message,
1005 text=internal_message,
1006 repo=repo.repo_id,
1006 repo=repo.repo_id,
1007 user=user.user_id,
1007 user=user.user_id,
@@ -22,7 +22,7 b' import pytest'
22
22
23 from rhodecode.tests.events.conftest import EventCatcher
23 from rhodecode.tests.events.conftest import EventCatcher
24
24
25 from rhodecode.model.comment import ChangesetCommentsModel
25 from rhodecode.model.comment import CommentsModel
26 from rhodecode.model.pull_request import PullRequestModel
26 from rhodecode.model.pull_request import PullRequestModel
27 from rhodecode.events import (
27 from rhodecode.events import (
28 PullRequestCreateEvent,
28 PullRequestCreateEvent,
@@ -61,7 +61,7 b' def test_create_pull_request_events(pr_u'
61 @pytest.mark.backends("git", "hg")
61 @pytest.mark.backends("git", "hg")
62 def test_pullrequest_comment_events_serialized(pr_util):
62 def test_pullrequest_comment_events_serialized(pr_util):
63 pr = pr_util.create_pull_request()
63 pr = pr_util.create_pull_request()
64 comment = ChangesetCommentsModel().get_comments(
64 comment = CommentsModel().get_comments(
65 pr.target_repo.repo_id, pull_request=pr)[0]
65 pr.target_repo.repo_id, pull_request=pr)[0]
66 event = PullRequestCommentEvent(pr, comment)
66 event = PullRequestCommentEvent(pr, comment)
67 data = event.as_dict()
67 data = event.as_dict()
@@ -72,7 +72,7 b' def test_diff_to_comment_line_number(old'
72 (DiffLineNumber(old=12, new=None), DiffLineNumber(old=21, new=None)),
72 (DiffLineNumber(old=12, new=None), DiffLineNumber(old=21, new=None)),
73 ])
73 ])
74 def test_choose_closest_diff_line_normal(diff_line, expected):
74 def test_choose_closest_diff_line_normal(diff_line, expected):
75 comment_model = comment.ChangesetCommentsModel()
75 comment_model = comment.CommentsModel()
76 candidates = [
76 candidates = [
77 DiffLineNumber(old=2, new=None),
77 DiffLineNumber(old=2, new=None),
78 DiffLineNumber(old=21, new=None),
78 DiffLineNumber(old=21, new=None),
@@ -82,7 +82,7 b' def test_choose_closest_diff_line_normal'
82
82
83
83
84 def test_revision_comments_are_sorted():
84 def test_revision_comments_are_sorted():
85 comment_model = comment.ChangesetCommentsModel()
85 comment_model = comment.CommentsModel()
86 query = comment_model._get_inline_comments_query(
86 query = comment_model._get_inline_comments_query(
87 repo_id='fake_repo_name',
87 repo_id='fake_repo_name',
88 revision='fake_revision',
88 revision='fake_revision',
@@ -92,15 +92,15 b' def test_revision_comments_are_sorted():'
92
92
93 @pytest.mark.parametrize('use_outdated', [True, False])
93 @pytest.mark.parametrize('use_outdated', [True, False])
94 def test_pull_request_comments_are_sorted(use_outdated):
94 def test_pull_request_comments_are_sorted(use_outdated):
95 comment_model = comment.ChangesetCommentsModel()
95 comment_model = comment.CommentsModel()
96 pull_request = mock.Mock()
96 pull_request = mock.Mock()
97 # TODO: johbo: Had to do this since we have an inline call to
97 # TODO: johbo: Had to do this since we have an inline call to
98 # self.__get_pull_request. Should be moved out at some point.
98 # self.__get_pull_request. Should be moved out at some point.
99 get_instance_patcher = mock.patch.object(
99 get_instance_patcher = mock.patch.object(
100 comment.ChangesetCommentsModel, '_get_instance',
100 comment.CommentsModel, '_get_instance',
101 return_value=pull_request)
101 return_value=pull_request)
102 config_patcher = mock.patch.object(
102 config_patcher = mock.patch.object(
103 comment.ChangesetCommentsModel, 'use_outdated_comments',
103 comment.CommentsModel, 'use_outdated_comments',
104 return_value=use_outdated)
104 return_value=use_outdated)
105
105
106 with get_instance_patcher, config_patcher as config_mock:
106 with get_instance_patcher, config_patcher as config_mock:
@@ -123,7 +123,7 b' def assert_inline_comments_order(query):'
123
123
124
124
125 def test_get_renderer():
125 def test_get_renderer():
126 model = comment.ChangesetCommentsModel()
126 model = comment.CommentsModel()
127 renderer = model._get_renderer()
127 renderer = model._get_renderer()
128 assert renderer == "rst"
128 assert renderer == "rst"
129
129
@@ -137,7 +137,7 b' class TestUseOutdatedComments(object):'
137 'rhodecode_use_outdated_comments': use_outdated
137 'rhodecode_use_outdated_comments': use_outdated
138 }
138 }
139 with self._patch_settings(general_settings) as settings_mock:
139 with self._patch_settings(general_settings) as settings_mock:
140 result = comment.ChangesetCommentsModel.use_outdated_comments(
140 result = comment.CommentsModel.use_outdated_comments(
141 pull_request)
141 pull_request)
142 settings_mock.assert_called_once_with(repo=pull_request.target_repo)
142 settings_mock.assert_called_once_with(repo=pull_request.target_repo)
143 assert result == use_outdated
143 assert result == use_outdated
@@ -147,7 +147,7 b' class TestUseOutdatedComments(object):'
147
147
148 general_settings = {}
148 general_settings = {}
149 with self._patch_settings(general_settings) as settings_mock:
149 with self._patch_settings(general_settings) as settings_mock:
150 result = comment.ChangesetCommentsModel.use_outdated_comments(
150 result = comment.CommentsModel.use_outdated_comments(
151 pull_request)
151 pull_request)
152 settings_mock.assert_called_once_with(repo=pull_request.target_repo)
152 settings_mock.assert_called_once_with(repo=pull_request.target_repo)
153 assert result is False
153 assert result is False
@@ -29,7 +29,7 b' from rhodecode.lib.vcs.backends.base imp'
29 MergeResponse, MergeFailureReason, Reference)
29 MergeResponse, MergeFailureReason, Reference)
30 from rhodecode.lib.vcs.exceptions import RepositoryError
30 from rhodecode.lib.vcs.exceptions import RepositoryError
31 from rhodecode.lib.vcs.nodes import FileNode
31 from rhodecode.lib.vcs.nodes import FileNode
32 from rhodecode.model.comment import ChangesetCommentsModel
32 from rhodecode.model.comment import CommentsModel
33 from rhodecode.model.db import PullRequest, Session
33 from rhodecode.model.db import PullRequest, Session
34 from rhodecode.model.pull_request import PullRequestModel
34 from rhodecode.model.pull_request import PullRequestModel
35 from rhodecode.model.user import UserModel
35 from rhodecode.model.user import UserModel
@@ -811,13 +811,13 b' def test_calculate_commits():'
811
811
812 def assert_inline_comments(pull_request, visible=None, outdated=None):
812 def assert_inline_comments(pull_request, visible=None, outdated=None):
813 if visible is not None:
813 if visible is not None:
814 inline_comments = ChangesetCommentsModel().get_inline_comments(
814 inline_comments = CommentsModel().get_inline_comments(
815 pull_request.target_repo.repo_id, pull_request=pull_request)
815 pull_request.target_repo.repo_id, pull_request=pull_request)
816 inline_cnt = ChangesetCommentsModel().get_inline_comments_count(
816 inline_cnt = CommentsModel().get_inline_comments_count(
817 inline_comments)
817 inline_comments)
818 assert inline_cnt == visible
818 assert inline_cnt == visible
819 if outdated is not None:
819 if outdated is not None:
820 outdated_comments = ChangesetCommentsModel().get_outdated_comments(
820 outdated_comments = CommentsModel().get_outdated_comments(
821 pull_request.target_repo.repo_id, pull_request)
821 pull_request.target_repo.repo_id, pull_request)
822 assert len(outdated_comments) == outdated
822 assert len(outdated_comments) == outdated
823
823
@@ -842,5 +842,5 b' def assert_pr_file_changes('
842
842
843 def outdated_comments_patcher(use_outdated=True):
843 def outdated_comments_patcher(use_outdated=True):
844 return mock.patch.object(
844 return mock.patch.object(
845 ChangesetCommentsModel, 'use_outdated_comments',
845 CommentsModel, 'use_outdated_comments',
846 return_value=use_outdated)
846 return_value=use_outdated)
@@ -39,7 +39,7 b' import requests'
39 import rhodecode
39 import rhodecode
40 from rhodecode.lib.utils2 import AttributeDict
40 from rhodecode.lib.utils2 import AttributeDict
41 from rhodecode.model.changeset_status import ChangesetStatusModel
41 from rhodecode.model.changeset_status import ChangesetStatusModel
42 from rhodecode.model.comment import ChangesetCommentsModel
42 from rhodecode.model.comment import CommentsModel
43 from rhodecode.model.db import (
43 from rhodecode.model.db import (
44 PullRequest, Repository, RhodeCodeSetting, ChangesetStatus, RepoGroup,
44 PullRequest, Repository, RhodeCodeSetting, ChangesetStatus, RepoGroup,
45 UserGroup, RepoRhodeCodeUi, RepoRhodeCodeSetting, RhodeCodeUi)
45 UserGroup, RepoRhodeCodeUi, RepoRhodeCodeSetting, RhodeCodeUi)
@@ -1038,7 +1038,7 b' class PRTestUtility(object):'
1038 return removed_commit_id
1038 return removed_commit_id
1039
1039
1040 def create_comment(self, linked_to=None):
1040 def create_comment(self, linked_to=None):
1041 comment = ChangesetCommentsModel().create(
1041 comment = CommentsModel().create(
1042 text=u"Test comment",
1042 text=u"Test comment",
1043 repo=self.target_repository.repo_name,
1043 repo=self.target_repository.repo_name,
1044 user=self.author,
1044 user=self.author,
@@ -1052,7 +1052,7 b' class PRTestUtility(object):'
1052
1052
1053 def create_inline_comment(
1053 def create_inline_comment(
1054 self, linked_to=None, line_no=u'n1', file_path='file_1'):
1054 self, linked_to=None, line_no=u'n1', file_path='file_1'):
1055 comment = ChangesetCommentsModel().create(
1055 comment = CommentsModel().create(
1056 text=u"Test comment",
1056 text=u"Test comment",
1057 repo=self.target_repository.repo_name,
1057 repo=self.target_repository.repo_name,
1058 user=self.author,
1058 user=self.author,
General Comments 0
You need to be logged in to leave comments. Login now