aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>2017-08-21 00:40:11 +1000
committerStephen Finucane <stephen@that.guru>2017-08-23 17:19:00 +0100
commitdebfe66b200fe007cb91248eab1537af667c1238 (patch)
tree9696013f7ee7c1c223e9b0db1953294d917b25b4
parent866d14b4c1ce64e20ec4d2e7b3dd7667188ab630 (diff)
downloadpatchwork-debfe66b200fe007cb91248eab1537af667c1238.tar
patchwork-debfe66b200fe007cb91248eab1537af667c1238.tar.gz
tests: Add test for updating tag counts in patch comments
We accidentally broke the updating of tag counts for tags in comments, and we didn't notice for quite a while. Add a test for this. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Reviewed-by: Stephen Finucane <stephen@that.guru>
-rw-r--r--patchwork/tests/test_parser.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py
index 52de351..583dfcc 100644
--- a/patchwork/tests/test_parser.py
+++ b/patchwork/tests/test_parser.py
@@ -75,19 +75,22 @@ def read_mail(filename, project=None):
return mail
-def _create_email(msg, msgid=None, sender=None, listid=None):
+def _create_email(msg, msgid=None, sender=None, listid=None, in_reply_to=None):
msg['Message-Id'] = msgid or make_msgid()
msg['Subject'] = 'Test subject'
msg['From'] = sender or 'Test Author <test-author@example.com>'
msg['List-Id'] = listid or 'test.example.com'
+ if in_reply_to:
+ msg['In-Reply-To'] = in_reply_to
return msg
-def create_email(content, msgid=None, sender=None, listid=None):
+def create_email(content, msgid=None, sender=None, listid=None,
+ in_reply_to=None):
msg = MIMEText(content, _charset='us-ascii')
- return _create_email(msg, msgid, sender, listid)
+ return _create_email(msg, msgid, sender, listid, in_reply_to)
def parse_mail(*args, **kwargs):
@@ -767,6 +770,34 @@ class ParseInitialTagsTest(PatchTest):
tag__name='Tested-by').count, 1)
+class ParseCommentTagsTest(PatchTest):
+ fixtures = ['default_tags']
+ patch_filename = '0001-add-line.patch'
+ comment_content = ('test comment\n\n' +
+ 'Tested-by: Test User <test@example.com>\n' +
+ 'Reviewed-by: Test User <test@example.com>\n')
+
+ def setUp(self):
+ project = create_project(listid='test.example.com')
+ self.orig_diff = read_patch(self.patch_filename)
+ email = create_email(self.orig_diff,
+ listid=project.listid)
+ parse_mail(email)
+ email2 = create_email(self.comment_content,
+ in_reply_to=email['Message-Id'])
+ parse_mail(email2)
+
+ def test_tags(self):
+ self.assertEqual(Patch.objects.count(), 1)
+ patch = Patch.objects.all()[0]
+ self.assertEqual(patch.patchtag_set.filter(
+ tag__name='Acked-by').count(), 0)
+ self.assertEqual(patch.patchtag_set.get(
+ tag__name='Reviewed-by').count, 1)
+ self.assertEqual(patch.patchtag_set.get(
+ tag__name='Tested-by').count, 1)
+
+
class SubjectTest(TestCase):
def test_clean_subject(self):