From: Andrew Donnellan Date: Sun, 20 Aug 2017 14:40:11 +0000 (+1000) Subject: tests: Add test for updating tag counts in patch comments X-Git-Tag: v2.0.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=debfe66b200fe007cb91248eab1537af667c1238;p=thirdparty%2Fpatchwork.git 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 Reviewed-by: Stephen Finucane --- diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index 52de351e..583dfcc4 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 ' 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 \n' + + 'Reviewed-by: Test User \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):