Changeset - cd32d44ee7ff
[Not reviewed]
default
0 2 0
Mads Kiilerich - 9 years ago 2016-07-28 16:28:34
madski@unity3d.com
tests: improve test data in test_notifications mail template dump test
2 files changed with 62 insertions and 54 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/models/test_dump_html_mails.ref.html
Show inline comments
 
<html><body>
 

	
 

	
 
<h1>cs_comment, is_mention=False, status_change=None</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Comment] repo/name changeset cafe on brunch
 
Subject: [Comment] repo/name changeset cafe1234 on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo_target changeset c0ffeecafe:
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff:
 
This is the new comment.
 

	
 
 - and here it ends indented.
 

	
 

	
 
URL: http://comment.org
 

	
 
Changeset: c0ffeecafe
 
Changeset: cafe1234c0ff
 
Description:
 
This changeset did something clever which is hard to explain
 

	
 

	
 
-- 
 
This is an automatic notification. Don't reply to this mail.
 

	
 
--------------------</pre>
 

	
 

	
 

	
 
<p>Comment from Commenter Name on repo_target changeset c0ffeecafe:</p>
 
<p>Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff:</p>
 
<p><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></p>
 

	
 

	
 
<p>URL: <a href="http://comment.org">http://comment.org</a></p>
 

	
 
<p>Changeset: c0ffeecafe</p>
 
<p>Changeset: cafe1234c0ff</p>
 
<p>Description:<br/>
 
This changeset did something clever which is hard to explain
 
</p>
 

	
 

	
 
<br/>
 
<br/>
 
-- <br/>
 
This is an automatic notification. Don&#39;t reply to this mail.
 

	
 
<pre>--------------------</pre>
 

	
 

	
 
<h1>cs_comment, is_mention=True, status_change=None</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Comment] repo/name changeset cafe on brunch
 
Subject: [Comment] repo/name changeset cafe1234 on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo_target changeset c0ffeecafe mentioned you:
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff mentioned you:
 
This is the new comment.
 

	
 
 - and here it ends indented.
 

	
 

	
 
URL: http://comment.org
 

	
 
Changeset: c0ffeecafe
 
Changeset: cafe1234c0ff
 
Description:
 
This changeset did something clever which is hard to explain
 

	
 

	
 
-- 
 
This is an automatic notification. Don't reply to this mail.
 

	
 
--------------------</pre>
 

	
 

	
 

	
 
<p>Comment from Commenter Name on repo_target changeset c0ffeecafe mentioned you:</p>
 
<p>Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff mentioned you:</p>
 
<p><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></p>
 

	
 

	
 
<p>URL: <a href="http://comment.org">http://comment.org</a></p>
 

	
 
<p>Changeset: c0ffeecafe</p>
 
<p>Changeset: cafe1234c0ff</p>
 
<p>Description:<br/>
 
This changeset did something clever which is hard to explain
 
</p>
 

	
 

	
 
<br/>
 
<br/>
 
-- <br/>
 
This is an automatic notification. Don&#39;t reply to this mail.
 

	
 
<pre>--------------------</pre>
 

	
 

	
 
<h1>cs_comment, is_mention=False, status_change='Approved'</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Approved: Comment] repo/name changeset cafe on brunch
 
Subject: [Approved: Comment] repo/name changeset cafe1234 on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo_target changeset c0ffeecafe:
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff:
 
This is the new comment.
 

	
 
 - and here it ends indented.
 

	
 
The changeset status was changed to: Approved
 

	
 
URL: http://comment.org
 

	
 
Changeset: c0ffeecafe
 
Changeset: cafe1234c0ff
 
Description:
 
This changeset did something clever which is hard to explain
 

	
 

	
 
-- 
 
This is an automatic notification. Don't reply to this mail.
 

	
 
--------------------</pre>
 

	
 

	
 

	
 
<p>Comment from Commenter Name on repo_target changeset c0ffeecafe:</p>
 
<p>Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff:</p>
 
<p><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></p>
 

	
 
    <p>The changeset status was changed to: <b>Approved</b></p>
 

	
 
<p>URL: <a href="http://comment.org">http://comment.org</a></p>
 

	
 
<p>Changeset: c0ffeecafe</p>
 
<p>Changeset: cafe1234c0ff</p>
 
<p>Description:<br/>
 
This changeset did something clever which is hard to explain
 
</p>
 

	
 

	
 
<br/>
 
<br/>
 
-- <br/>
 
This is an automatic notification. Don&#39;t reply to this mail.
 

	
 
<pre>--------------------</pre>
 

	
 

	
 
<h1>cs_comment, is_mention=True, status_change='Approved'</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Approved: Comment] repo/name changeset cafe on brunch
 
Subject: [Approved: Comment] repo/name changeset cafe1234 on brunch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo_target changeset c0ffeecafe mentioned you:
 
Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff mentioned you:
 
This is the new comment.
 

	
 
 - and here it ends indented.
 

	
 
The changeset status was changed to: Approved
 

	
 
URL: http://comment.org
 

	
 
Changeset: c0ffeecafe
 
Changeset: cafe1234c0ff
 
Description:
 
This changeset did something clever which is hard to explain
 

	
 

	
 
-- 
 
This is an automatic notification. Don't reply to this mail.
 

	
 
--------------------</pre>
 

	
 

	
 

	
 
<p>Comment from Commenter Name on repo_target changeset c0ffeecafe mentioned you:</p>
 
<p>Comment from Opinionated User (jsmith) on repo_target changeset cafe1234c0ff mentioned you:</p>
 
<p><div class="formatted-fixed">This is the new comment.
 

	
 
 - and here it ends indented.</div></p>
 

	
 
    <p>The changeset status was changed to: <b>Approved</b></p>
 

	
 
<p>URL: <a href="http://comment.org">http://comment.org</a></p>
 

	
 
<p>Changeset: c0ffeecafe</p>
 
<p>Changeset: cafe1234c0ff</p>
 
<p>Description:<br/>
 
This changeset did something clever which is hard to explain
 
</p>
 

	
 

	
 
<br/>
 
<br/>
 
-- <br/>
 
This is an automatic notification. Don&#39;t reply to this mail.
 

	
 
<pre>--------------------</pre>
 

	
 
@@ -277,300 +277,308 @@ View this user here: <a href="http://new
 
<br/>
 
-- <br/>
 
This is an automatic notification. Don&#39;t reply to this mail.
 

	
 
<pre>--------------------</pre>
 

	
 

	
 
<h1>pull_request, is_mention=False</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Added] repo/name pull request 7 from ref
 
Subject: [Added] repo/name pull request #7 from devbranch
 

	
 
--------------------
 

	
 

	
 
Requester Name requested your review of repo/name pull request "The Title"
 
Requesting User (root) requested your review of repo/name pull request "The Title"
 

	
 
URL: http://pr.org
 
URL: http://pr.org/7
 

	
 
Description:
 
This PR is awesome because it does stuff
 
 - please approve indented!
 

	
 
Changesets:
 
123abc: http://changeset_home/?repo_name=repo_org&amp;revision=123abc
 
123abc123abc: http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc
 
Introduce one and two
 

	
 
567fed: http://changeset_home/?repo_name=repo_org&amp;revision=567fed
 
and that's it
 

	
 
567fed567fed: http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed
 
Make one plus two equal tree
 

	
 

	
 

	
 
-- 
 
This is an automatic notification. Don't reply to this mail.
 

	
 
--------------------</pre>
 

	
 

	
 

	
 
<p>Requester Name requested your review of repo/name pull request &#34;The Title&#34;</p>
 
<p>Requesting User (root) requested your review of repo/name pull request &#34;The Title&#34;</p>
 

	
 
<p>URL: <a href="http://pr.org">http://pr.org</a></p>
 
<p>URL: <a href="http://pr.org/7">http://pr.org/7</a></p>
 

	
 
<p>Description:</p>
 
<p style="white-space: pre-wrap; font-family: monospace"><div class="formatted-fixed">This PR is awesome because it does stuff
 
 - please approve indented!</div></p>
 

	
 
<p>Changesets:</p>
 
<p style="white-space: pre-wrap">
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc">123abc</a></i>:
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc">123abc123abc</a></i>:
 
Introduce one and two
 

	
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed">567fed</a></i>:
 
and that&#39;s it
 

	
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed">567fed567fed</a></i>:
 
Make one plus two equal tree
 

	
 
</p>
 

	
 

	
 
<br/>
 
<br/>
 
-- <br/>
 
This is an automatic notification. Don&#39;t reply to this mail.
 

	
 
<pre>--------------------</pre>
 

	
 

	
 
<h1>pull_request, is_mention=True</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Added] repo/name pull request 7 from ref
 
Subject: [Added] repo/name pull request #7 from devbranch
 

	
 
--------------------
 

	
 

	
 
Requester Name mentioned you on repo/name pull request "The Title"
 
Requesting User (root) mentioned you on repo/name pull request "The Title"
 

	
 
URL: http://pr.org
 
URL: http://pr.org/7
 

	
 
Description:
 
This PR is awesome because it does stuff
 
 - please approve indented!
 

	
 
Changesets:
 
123abc: http://changeset_home/?repo_name=repo_org&amp;revision=123abc
 
123abc123abc: http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc
 
Introduce one and two
 

	
 
567fed: http://changeset_home/?repo_name=repo_org&amp;revision=567fed
 
and that's it
 

	
 
567fed567fed: http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed
 
Make one plus two equal tree
 

	
 

	
 

	
 
-- 
 
This is an automatic notification. Don't reply to this mail.
 

	
 
--------------------</pre>
 

	
 

	
 

	
 
<p>Requester Name mentioned you on repo/name pull request &#34;The Title&#34;</p>
 
<p>Requesting User (root) mentioned you on repo/name pull request &#34;The Title&#34;</p>
 

	
 
<p>URL: <a href="http://pr.org">http://pr.org</a></p>
 
<p>URL: <a href="http://pr.org/7">http://pr.org/7</a></p>
 

	
 
<p>Description:</p>
 
<p style="white-space: pre-wrap; font-family: monospace"><div class="formatted-fixed">This PR is awesome because it does stuff
 
 - please approve indented!</div></p>
 

	
 
<p>Changesets:</p>
 
<p style="white-space: pre-wrap">
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc">123abc</a></i>:
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=123abc123abc123abc123abc123abc123abc123abc">123abc123abc</a></i>:
 
Introduce one and two
 

	
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed">567fed</a></i>:
 
and that&#39;s it
 

	
 
<i><a href="http://changeset_home/?repo_name=repo_org&amp;revision=567fed567fed567fed567fed567fed567fed567fed">567fed567fed</a></i>:
 
Make one plus two equal tree
 

	
 
</p>
 

	
 

	
 
<br/>
 
<br/>
 
-- <br/>
 
This is an automatic notification. Don&#39;t reply to this mail.
 

	
 
<pre>--------------------</pre>
 

	
 

	
 
<h1>pull_request_comment, status_change=None, closing_pr=False</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Comment] repo/name pull request 7 from ref
 
Subject: [Comment] repo/name pull request #7 from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo/name pull request "The Title":
 
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 Commenter Name on repo/name pull request &#34;The Title&#34;:</p>
 
<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, 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 ref
 
Subject: [Under Review: Comment] repo/name pull request #7 from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo/name pull request "The Title":
 
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 Commenter Name on repo/name pull request &#34;The Title&#34;:</p>
 
<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, status_change=None, closing_pr=True</h1>
 
<pre>
 

	
 
From: u1
 
To: u2@example.com
 
Subject: [Closing: Comment] repo/name pull request 7 from ref
 
Subject: [Closing: Comment] repo/name pull request #7 from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo/name pull request "The Title":
 
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 Commenter Name on repo/name pull request &#34;The Title&#34;:</p>
 
<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, 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 ref
 
Subject: [Under Review, Closing: Comment] repo/name pull request #7 from devbranch
 

	
 
--------------------
 

	
 

	
 
Comment from Commenter Name on repo/name pull request "The Title":
 
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 Commenter Name on repo/name pull request &#34;The Title&#34;:</p>
 
<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/>
kallithea/tests/models/test_notifications.py
Show inline comments
 
@@ -173,33 +173,33 @@ class TestNotifications(TestController):
 
            l.append('\n\n<h1>%s</h1>\n' % desc) # desc is from outer scope
 
            l.append('<pre>\n\n')
 
            l.append('From: %s\n' % author.username)
 
            l.append('To: %s\n' % ' '.join(recipients))
 
            l.append('Subject: %s\n' % subject)
 
            l.append('\n--------------------\n%s\n--------------------' % body)
 
            l.append('</pre>\n')
 
            l.append('\n%s\n' % html_body)
 
            l.append('<pre>--------------------</pre>\n')
 

	
 
        l.append('<html><body>\n')
 
        with mock.patch.object(kallithea.lib.celerylib.tasks, 'send_email', send_email):
 
            pr_kwargs = dict(pr_nice_id='7', ref='ref', org_repo_name='repo_org', pr_title='The Title', pr_url='http://pr.org')
 
            pr_kwargs = dict(pr_nice_id='#7', ref='devbranch', org_repo_name='repo_org', pr_title='The Title', pr_url='http://pr.org/7')
 

	
 
            for type_, body, kwargs in [
 
                (Notification.TYPE_CHANGESET_COMMENT, u'This is the new comment.\n\n - and here it ends indented.', dict(short_id='cafe', raw_id='c0ffeecafe', branch='brunch', cs_comment_user='Commenter Name', cs_comment_url='http://comment.org', is_mention=[False, True], message='This changeset did something clever which is hard to explain', status_change=[None, 'Approved'], cs_target_repo='repo_target', cs_url='http://changeset.com')),
 
                (Notification.TYPE_CHANGESET_COMMENT, u'This is the new comment.\n\n - and here it ends indented.', dict(short_id='cafe1234', raw_id='cafe1234c0ffeecafe', branch='brunch', cs_comment_user='Opinionated User (jsmith)', cs_comment_url='http://comment.org', is_mention=[False, True], message='This changeset did something clever which is hard to explain', status_change=[None, 'Approved'], cs_target_repo='repo_target', cs_url='http://changeset.com')),
 
                (Notification.TYPE_MESSAGE, u'This is the body of the test message\n - nothing interesting here except indentation.', dict()),
 
                #(Notification.TYPE_MENTION, '$body', None), # not used
 
                (Notification.TYPE_REGISTRATION, u'Registration body', dict(new_username='newbie', registered_user_url='http://newbie.org', new_email='new@email.com', new_full_name='New Full Name')),
 
                (Notification.TYPE_PULL_REQUEST, u'This PR is awesome because it does stuff\n - please approve indented!', dict(pr_user_created='Requester Name', is_mention=[False, True], pr_revisions=[('123abc', 'Introduce one and two'), ('567fed', 'Make one plus two equal tree')], **pr_kwargs)),
 
                (Notification.TYPE_PULL_REQUEST_COMMENT, u'Me too!\n\n - and indented on second line', dict(closing_pr=[False, True], pr_comment_user='Commenter Name', pr_comment_url='http://pr.org/comment', status_change=[None, 'Under Review'], pr_target_repo='http://target.com/repo', **pr_kwargs)),
 
                (Notification.TYPE_PULL_REQUEST, u'This PR is awesome because it does stuff\n - please approve indented!', dict(pr_user_created='Requesting User (root)', is_mention=[False, True], pr_revisions=[('123abc'*7, "Introduce one and two\n\nand that's it"), ('567fed'*7, 'Make one plus two equal tree')], **pr_kwargs)),
 
                (Notification.TYPE_PULL_REQUEST_COMMENT, u'Me too!\n\n - and indented on second line', dict(closing_pr=[False, True], pr_comment_user='Opinionated User (jsmith)', pr_comment_url='http://pr.org/comment', status_change=[None, 'Under Review'], pr_target_repo='http://target.com/repo', **pr_kwargs)),
 
                ]:
 
                kwargs['repo_name'] = u'repo/name'
 
                params = [(type_, type_, body, kwargs)]
 
                for param_name in ['is_mention', 'status_change', 'closing_pr']: # TODO: inline/general
 
                    if not isinstance(kwargs.get(param_name), list):
 
                        continue
 
                    new_params = []
 
                    for v in kwargs[param_name]:
 
                        for desc, type_, body, kwargs in params:
 
                            kwargs = dict(kwargs)
 
                            kwargs[param_name] = v
 
                            new_params.append(('%s, %s=%r' % (desc, param_name, v), type_, body, kwargs))
0 comments (0 inline, 0 general)