changeset 6057:552800808386

tests: add test coverage of PR comment @mention
author Mads Kiilerich <madski@unity3d.com>
date Thu, 28 Jul 2016 16:31:40 +0200
parents 3a221939a19f
children bd5d70b6f445
files kallithea/model/comment.py kallithea/model/pull_request.py kallithea/tests/models/test_dump_html_mails.ref.html kallithea/tests/models/test_notifications.py
diffstat 4 files changed, 183 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/comment.py	Thu Jul 28 16:30:28 2016 +0200
+++ b/kallithea/model/comment.py	Thu Jul 28 16:31:40 2016 +0200
@@ -213,6 +213,7 @@
             if mention_recipients:
                 email_kwargs['is_mention'] = True
                 subj = _('[Mention]') + ' ' + subj
+                # FIXME: this subject is wrong and unused!
                 NotificationModel().create(
                     created_by=user, subject=subj, body=body,
                     recipients=mention_recipients,
--- a/kallithea/model/pull_request.py	Thu Jul 28 16:30:28 2016 +0200
+++ b/kallithea/model/pull_request.py	Thu Jul 28 16:31:40 2016 +0200
@@ -185,6 +185,7 @@
         if mention_recipients:
             email_kwargs['is_mention'] = True
             subject = _('[Mention]') + ' ' + subject
+            # FIXME: this subject is wrong and unused!
             NotificationModel().create(created_by=user, subject=subject, body=body,
                                        recipients=mention_recipients,
                                        type_=Notification.TYPE_PULL_REQUEST,
--- a/kallithea/tests/models/test_dump_html_mails.ref.html	Thu Jul 28 16:30:28 2016 +0200
+++ b/kallithea/tests/models/test_dump_html_mails.ref.html	Thu Jul 28 16:31:40 2016 +0200
@@ -411,7 +411,7 @@
 <pre>--------------------</pre>
 
 
-<h1>pull_request_comment, status_change=None, closing_pr=False</h1>
+<h1>pull_request_comment, is_mention=False, status_change=None, closing_pr=False</h1>
 <pre>
 
 From: u1
@@ -454,7 +454,50 @@
 <pre>--------------------</pre>
 
 
-<h1>pull_request_comment, status_change='Under Review', closing_pr=False</h1>
+<h1>pull_request_comment, is_mention=True, status_change=None, closing_pr=False</h1>
+<pre>
+
+From: u1
+To: u2@example.com
+Subject: [Comment] repo/name pull request #7 from devbranch
+
+--------------------
+
+
+Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
+Me too!
+
+ - and indented on second line
+
+
+URL: http://pr.org/comment
+
+
+--
+This is an automatic notification. Don't reply to this mail.
+
+--------------------</pre>
+
+
+
+<p>Comment from Opinionated User (jsmith) on repo/name pull request &#34;The Title&#34;:</p>
+<p><div class="formatted-fixed">Me too!
+
+ - and indented on second line</div></p>
+
+
+<p>URL: <a href="http://pr.org/comment">http://pr.org/comment</a></p>
+
+
+<br/>
+<br/>
+-- <br/>
+This is an automatic notification. Don&#39;t reply to this mail.
+
+<pre>--------------------</pre>
+
+
+<h1>pull_request_comment, is_mention=False, status_change='Under Review', closing_pr=False</h1>
 <pre>
 
 From: u1
@@ -499,7 +542,52 @@
 <pre>--------------------</pre>
 
 
-<h1>pull_request_comment, status_change=None, closing_pr=True</h1>
+<h1>pull_request_comment, is_mention=True, status_change='Under Review', closing_pr=False</h1>
+<pre>
+
+From: u1
+To: u2@example.com
+Subject: [Under Review: Comment] repo/name pull request #7 from devbranch
+
+--------------------
+
+
+Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
+Me too!
+
+ - and indented on second line
+
+The comment was made with status: Under Review
+
+URL: http://pr.org/comment
+
+
+--
+This is an automatic notification. Don't reply to this mail.
+
+--------------------</pre>
+
+
+
+<p>Comment from Opinionated User (jsmith) on repo/name pull request &#34;The Title&#34;:</p>
+<p><div class="formatted-fixed">Me too!
+
+ - and indented on second line</div></p>
+
+       <p>The comment was made with status: <b>Under Review</b></p>
+
+<p>URL: <a href="http://pr.org/comment">http://pr.org/comment</a></p>
+
+
+<br/>
+<br/>
+-- <br/>
+This is an automatic notification. Don&#39;t reply to this mail.
+
+<pre>--------------------</pre>
+
+
+<h1>pull_request_comment, is_mention=False, status_change=None, closing_pr=True</h1>
 <pre>
 
 From: u1
@@ -542,7 +630,95 @@
 <pre>--------------------</pre>
 
 
-<h1>pull_request_comment, status_change='Under Review', closing_pr=True</h1>
+<h1>pull_request_comment, is_mention=True, status_change=None, closing_pr=True</h1>
+<pre>
+
+From: u1
+To: u2@example.com
+Subject: [Closing: Comment] repo/name pull request #7 from devbranch
+
+--------------------
+
+
+Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
+Me too!
+
+ - and indented on second line
+
+
+URL: http://pr.org/comment
+
+
+--
+This is an automatic notification. Don't reply to this mail.
+
+--------------------</pre>
+
+
+
+<p>Comment from Opinionated User (jsmith) on repo/name pull request &#34;The Title&#34;:</p>
+<p><div class="formatted-fixed">Me too!
+
+ - and indented on second line</div></p>
+
+
+<p>URL: <a href="http://pr.org/comment">http://pr.org/comment</a></p>
+
+
+<br/>
+<br/>
+-- <br/>
+This is an automatic notification. Don&#39;t reply to this mail.
+
+<pre>--------------------</pre>
+
+
+<h1>pull_request_comment, is_mention=False, status_change='Under Review', closing_pr=True</h1>
+<pre>
+
+From: u1
+To: u2@example.com
+Subject: [Under Review, Closing: Comment] repo/name pull request #7 from devbranch
+
+--------------------
+
+
+Comment from Opinionated User (jsmith) on repo/name pull request "The Title":
+Me too!
+
+ - and indented on second line
+
+The comment closed the pull request with status: Under Review
+
+URL: http://pr.org/comment
+
+
+--
+This is an automatic notification. Don't reply to this mail.
+
+--------------------</pre>
+
+
+
+<p>Comment from Opinionated User (jsmith) on repo/name pull request &#34;The Title&#34;:</p>
+<p><div class="formatted-fixed">Me too!
+
+ - and indented on second line</div></p>
+
+       <p>The comment closed the pull request with status: <b>Under Review</b></p>
+
+<p>URL: <a href="http://pr.org/comment">http://pr.org/comment</a></p>
+
+
+<br/>
+<br/>
+-- <br/>
+This is an automatic notification. Don&#39;t reply to this mail.
+
+<pre>--------------------</pre>
+
+
+<h1>pull_request_comment, is_mention=True, status_change='Under Review', closing_pr=True</h1>
 <pre>
 
 From: u1
--- a/kallithea/tests/models/test_notifications.py	Thu Jul 28 16:30:28 2016 +0200
+++ b/kallithea/tests/models/test_notifications.py	Thu Jul 28 16:31:40 2016 +0200
@@ -231,6 +231,7 @@
                  u'Me too!\n\n - and indented on second line',
                  dict(
                     closing_pr=[False, True],
+                    is_mention=[False, True],
                     pr_comment_user='Opinionated User (jsmith)',
                     pr_comment_url='http://pr.org/comment',
                     status_change=[None, 'Under Review'],