Files
@ 3e6f0b5815d8
Branch filter:
Location: kallithea/kallithea/tests/functional/test_changeset_pullrequests_comments.py
3e6f0b5815d8
16.6 KiB
text/x-python
templates: remove notification count from user profile button
This commit is part of the removal of the UI notification feature from
Kallithea, which is not deemed useful in its current form. Only email
notifications are preserved.
This commit removes the notification count 'badge' next to the username
top-right, and the count in the expanded field when clicking that username.
This commit is part of the removal of the UI notification feature from
Kallithea, which is not deemed useful in its current form. Only email
notifications are preserved.
This commit removes the notification count 'badge' next to the username
top-right, and the count in the expanded field when clicking that username.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | import re
from kallithea.tests.base import *
from kallithea.model.changeset_status import ChangesetStatusModel
from kallithea.model.db import ChangesetComment, Notification, \
UserNotification
from kallithea.model.meta import Session
class TestChangeSetCommentsController(TestController):
def setup_method(self, method):
for x in ChangesetComment.query().all():
Session().delete(x)
Session().commit()
self.remove_all_notifications()
def test_create(self):
self.log_user()
rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
text = u'general comment on changeset'
params = {'text': text, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='changeset', action='comment',
repo_name=HG_REPO, revision=rev),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='changeset', action='index',
repo_name=HG_REPO, revision=rev))
response.mustcontain(
'''<div class="comments-number">'''
''' 1 comment (0 inline, 1 general)'''
)
response.mustcontain(text)
# test DB
assert ChangesetComment.query().count() == 1
assert Notification.query().count() == 1
notification = Notification.query().all()[0]
comment_id = ChangesetComment.query().first().comment_id
assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
sbj = (u'/%s/changeset/'
'27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s'
% (HG_REPO, comment_id))
print "%s vs %s" % (sbj, notification.subject)
assert sbj in notification.subject
def test_create_inline(self):
self.log_user()
rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
text = u'inline comment on changeset'
f_path = 'vcs/web/simplevcs/views/repository.py'
line = 'n1'
params = {'text': text, 'f_path': f_path, 'line': line, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='changeset', action='comment',
repo_name=HG_REPO, revision=rev),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='changeset', action='index',
repo_name=HG_REPO, revision=rev))
response.mustcontain(
'''<div class="comments-number">'''
''' 1 comment (1 inline, 0 general)'''
)
response.mustcontain(
'''<div class="comments-list-chunk" '''
'''data-f_path="vcs/web/simplevcs/views/repository.py" '''
'''data-line_no="n1" data-target-id="vcswebsimplevcsviewsrepositorypy_n1">'''
)
response.mustcontain(text)
# test DB
assert ChangesetComment.query().count() == 1
assert Notification.query().count() == 1
notification = Notification.query().all()[0]
comment_id = ChangesetComment.query().first().comment_id
assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
sbj = (u'/%s/changeset/'
'27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s'
% (HG_REPO, comment_id))
print "%s vs %s" % (sbj, notification.subject)
assert sbj in notification.subject
def test_create_with_mention(self):
self.log_user()
rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
text = u'@%s check CommentOnRevision' % TEST_USER_REGULAR_LOGIN
params = {'text': text, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='changeset', action='comment',
repo_name=HG_REPO, revision=rev),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='changeset', action='index',
repo_name=HG_REPO, revision=rev))
response.mustcontain(
'''<div class="comments-number">'''
''' 1 comment (0 inline, 1 general)'''
)
response.mustcontain('<b>@%s</b> check CommentOnRevision' % TEST_USER_REGULAR_LOGIN)
# test DB
assert ChangesetComment.query().count() == 1
assert Notification.query().count() == 2
users = [x.user.username for x in UserNotification.query().all()]
# test_regular gets notification by @mention
assert sorted(users) == [TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN]
def test_create_status_change(self):
self.log_user()
rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
text = u'general comment on changeset'
params = {'text': text, 'changeset_status': 'rejected',
'_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='changeset', action='comment',
repo_name=HG_REPO, revision=rev),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='changeset', action='index',
repo_name=HG_REPO, revision=rev))
response.mustcontain(
'''<div class="comments-number">'''
''' 1 comment (0 inline, 1 general)'''
)
response.mustcontain(text)
# test DB
assert ChangesetComment.query().count() == 1
assert Notification.query().count() == 1
notification = Notification.query().all()[0]
comment_id = ChangesetComment.query().first().comment_id
assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
sbj = (u'/%s/changeset/'
'27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s'
% (HG_REPO, comment_id))
print "%s vs %s" % (sbj, notification.subject)
assert sbj in notification.subject
# check status
status = ChangesetStatusModel().get_status(repo=HG_REPO, revision=rev)
assert status == 'rejected'
def test_delete(self):
self.log_user()
rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
text = u'general comment on changeset to be deleted'
params = {'text': text, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='changeset', action='comment',
repo_name=HG_REPO, revision=rev),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
comments = ChangesetComment.query().all()
assert len(comments) == 1
comment_id = comments[0].comment_id
self.app.post(url("changeset_comment_delete",
repo_name=HG_REPO,
comment_id=comment_id),
params={'_authentication_token': self.authentication_token()})
comments = ChangesetComment.query().all()
assert len(comments) == 0
response = self.app.get(url(controller='changeset', action='index',
repo_name=HG_REPO, revision=rev))
response.mustcontain(
'''<div class="comments-number">'''
''' 0 comments (0 inline, 0 general)'''
)
response.mustcontain(no=text)
class TestPullrequestsCommentsController(TestController):
def setup_method(self, method):
for x in ChangesetComment.query().all():
Session().delete(x)
Session().commit()
self.remove_all_notifications()
def _create_pr(self):
response = self.app.post(url(controller='pullrequests', action='create',
repo_name=HG_REPO),
{'org_repo': HG_REPO,
'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a',
'other_repo': HG_REPO,
'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e',
'pullrequest_title': 'title',
'pullrequest_desc': 'description',
'_authentication_token': self.authentication_token(),
},
status=302)
pr_id = int(re.search('/pull-request/(\d+)/', response.location).group(1))
return pr_id
def test_create(self):
self.log_user()
pr_id = self._create_pr()
text = u'general comment on pullrequest'
params = {'text': text, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='pullrequests', action='comment',
repo_name=HG_REPO, pull_request_id=pr_id),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='pullrequests', action='show',
repo_name=HG_REPO, pull_request_id=pr_id, extra=''))
# PRs currently always have an initial 'Under Review' status change
# that counts as a general comment, hence '2' in the test below. That
# could be counted as a misfeature, to be reworked later.
response.mustcontain(
'''<div class="comments-number">'''
''' 2 comments (0 inline, 2 general)'''
)
response.mustcontain(text)
# test DB
assert ChangesetComment.query().count() == 2
assert Notification.query().count() == 1
notification = Notification.query().all()[0]
comment_id = ChangesetComment.query().order_by(ChangesetComment.comment_id.desc()).first().comment_id
assert notification.type_ == Notification.TYPE_PULL_REQUEST_COMMENT
sbj = (u'/%s/pull-request/%s/_/stable#comment-%s'
% (HG_REPO, pr_id, comment_id))
print "%s vs %s" % (sbj, notification.subject)
assert sbj in notification.subject
def test_create_inline(self):
self.log_user()
pr_id = self._create_pr()
text = u'inline comment on changeset'
f_path = 'vcs/web/simplevcs/views/repository.py'
line = 'n1'
params = {'text': text, 'f_path': f_path, 'line': line, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='pullrequests', action='comment',
repo_name=HG_REPO, pull_request_id=pr_id),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='pullrequests', action='show',
repo_name=HG_REPO, pull_request_id=pr_id, extra=''))
response.mustcontain(
'''<div class="comments-number">'''
''' 2 comments (1 inline, 1 general)'''
)
response.mustcontain(
'''<div class="comments-list-chunk" '''
'''data-f_path="vcs/web/simplevcs/views/repository.py" '''
'''data-line_no="n1" data-target-id="vcswebsimplevcsviewsrepositorypy_n1">'''
)
response.mustcontain(text)
# test DB
assert ChangesetComment.query().count() == 2
assert Notification.query().count() == 1
notification = Notification.query().all()[0]
comment_id = ChangesetComment.query().order_by(ChangesetComment.comment_id.desc()).first().comment_id
assert notification.type_ == Notification.TYPE_PULL_REQUEST_COMMENT
sbj = (u'/%s/pull-request/%s/_/stable#comment-%s'
% (HG_REPO, pr_id, comment_id))
print "%s vs %s" % (sbj, notification.subject)
assert sbj in notification.subject
def test_create_with_mention(self):
self.log_user()
pr_id = self._create_pr()
text = u'@%s check CommentOnRevision' % TEST_USER_REGULAR_LOGIN
params = {'text': text, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='pullrequests', action='comment',
repo_name=HG_REPO, pull_request_id=pr_id),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='pullrequests', action='show',
repo_name=HG_REPO, pull_request_id=pr_id, extra=''))
response.mustcontain(
'''<div class="comments-number">'''
''' 2 comments (0 inline, 2 general)'''
)
response.mustcontain('<b>@%s</b> check CommentOnRevision' % TEST_USER_REGULAR_LOGIN)
# test DB
assert ChangesetComment.query().count() == 2
assert Notification.query().count() == 2
users = [x.user.username for x in UserNotification.query().all()]
# test_regular gets notification by @mention
assert sorted(users) == [TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN]
def test_create_status_change(self):
self.log_user()
pr_id = self._create_pr()
text = u'general comment on pullrequest'
params = {'text': text, 'changeset_status': 'rejected',
'_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='pullrequests', action='comment',
repo_name=HG_REPO, pull_request_id=pr_id),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
# Test response...
assert response.status == '200 OK'
response = self.app.get(url(controller='pullrequests', action='show',
repo_name=HG_REPO, pull_request_id=pr_id, extra=''))
# PRs currently always have an initial 'Under Review' status change
# that counts as a general comment, hence '2' in the test below. That
# could be counted as a misfeature, to be reworked later.
response.mustcontain(
'''<div class="comments-number">'''
''' 2 comments (0 inline, 2 general)'''
)
response.mustcontain(text)
# test DB
assert ChangesetComment.query().count() == 2
assert Notification.query().count() == 1
notification = Notification.query().all()[0]
comment_id = ChangesetComment.query().order_by(ChangesetComment.comment_id.desc()).first().comment_id
assert notification.type_ == Notification.TYPE_PULL_REQUEST_COMMENT
sbj = (u'/%s/pull-request/%s/_/stable#comment-%s'
% (HG_REPO, pr_id, comment_id))
print "%s vs %s" % (sbj, notification.subject)
assert sbj in notification.subject
# check status
status = ChangesetStatusModel().get_status(repo=HG_REPO, pull_request=pr_id)
assert status == 'rejected'
def test_delete(self):
self.log_user()
pr_id = self._create_pr()
text = u'general comment on changeset to be deleted'
params = {'text': text, '_authentication_token': self.authentication_token()}
response = self.app.post(url(controller='pullrequests', action='comment',
repo_name=HG_REPO, pull_request_id=pr_id),
params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
comments = ChangesetComment.query().all()
assert len(comments) == 2
comment_id = comments[-1].comment_id
self.app.post(url("pullrequest_comment_delete",
repo_name=HG_REPO,
comment_id=comment_id),
params={'_authentication_token': self.authentication_token()})
comments = ChangesetComment.query().all()
assert len(comments) == 1
response = self.app.get(url(controller='pullrequests', action='show',
repo_name=HG_REPO, pull_request_id=pr_id, extra=''))
response.mustcontain(
'''<div class="comments-number">'''
''' 1 comment (0 inline, 1 general)'''
)
response.mustcontain(no=text)
|