[PATCH 01 of 14] tests: small improvements to test_changeset_comments

Thomas De Schampheleire patrickdepinguin at gmail.com
Tue Nov 20 20:32:12 UTC 2018


# HG changeset patch
# User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
# Date 1542488061 -3600
#      Sat Nov 17 21:54:21 2018 +0100
# Node ID e08990571c3b02abc9b0991321fc2ee02b1761b3
# Parent  b1652bba9eccdc0957142176094069b4a2534b94
tests: small improvements to test_changeset_comments

- response checking is incorrectly placed under 'Test DB' comment
- no response check on the comment text was done
- related: use different text for the comments in different tests
- commit_id should be comment_id
- remove duplicate checking of comment count in DB

diff --git a/kallithea/tests/functional/test_changeset_comments.py b/kallithea/tests/functional/test_changeset_comments.py
--- a/kallithea/tests/functional/test_changeset_comments.py
+++ b/kallithea/tests/functional/test_changeset_comments.py
@@ -16,7 +16,7 @@ class TestChangeSetCommentsController(Te
     def test_create(self):
         self.log_user()
         rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
-        text = u'CommentOnRevision'
+        text = u'general comment on changeset'
 
         params = {'text': text, '_authentication_token': self.authentication_token()}
         response = self.app.post(url(controller='changeset', action='comment',
@@ -27,30 +27,30 @@ class TestChangeSetCommentsController(Te
 
         response = self.app.get(url(controller='changeset', action='index',
                                 repo_name=HG_REPO, revision=rev))
-        # test DB
-        assert ChangesetComment.query().count() == 1
         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
-        assert ChangesetComment.query().count() == 1
 
         notification = Notification.query().all()[0]
 
-        commit_id = ChangesetComment.query().first().comment_id
+        comment_id = ChangesetComment.query().first().comment_id
         assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
         sbj = (u'/%s/changeset/'
                '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s'
-               % (HG_REPO, commit_id))
+               % (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'CommentOnRevision'
+        text = u'inline comment on changeset'
         f_path = 'vcs/web/simplevcs/views/repository.py'
         line = 'n1'
 
@@ -63,8 +63,6 @@ class TestChangeSetCommentsController(Te
 
         response = self.app.get(url(controller='changeset', action='index',
                                 repo_name=HG_REPO, revision=rev))
-        # test DB
-        assert ChangesetComment.query().count() == 1
         response.mustcontain(
             '''<div class="comments-number">'''
             ''' 1 comment (1 inline, 0 general)'''
@@ -74,16 +72,18 @@ class TestChangeSetCommentsController(Te
             '''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
-        assert ChangesetComment.query().count() == 1
 
         notification = Notification.query().all()[0]
-        commit_id = ChangesetComment.query().first().comment_id
+        comment_id = ChangesetComment.query().first().comment_id
         assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
         sbj = (u'/%s/changeset/'
                '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s'
-               % (HG_REPO, commit_id))
+               % (HG_REPO, comment_id))
         print "%s vs %s" % (sbj, notification.subject)
         assert sbj in notification.subject
 
@@ -102,13 +102,14 @@ class TestChangeSetCommentsController(Te
 
         response = self.app.get(url(controller='changeset', action='index',
                                 repo_name=HG_REPO, revision=rev))
-        # test DB
-        assert ChangesetComment.query().count() == 1
         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()]
 
@@ -118,7 +119,7 @@ class TestChangeSetCommentsController(Te
     def test_delete(self):
         self.log_user()
         rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
-        text = u'CommentOnRevision'
+        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',
@@ -143,3 +144,4 @@ class TestChangeSetCommentsController(Te
             '''<div class="comments-number">'''
             ''' 0 comments (0 inline, 0 general)'''
         )
+        response.mustcontain(no=text)


More information about the kallithea-general mailing list