Skip to content

Commit debfe66

Browse files
ajdlinuxstephenfin
authored andcommitted
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 <[email protected]> Reviewed-by: Stephen Finucane <[email protected]>
1 parent 866d14b commit debfe66

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

patchwork/tests/test_parser.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,22 @@ def read_mail(filename, project=None):
7575
return mail
7676

7777

78-
def _create_email(msg, msgid=None, sender=None, listid=None):
78+
def _create_email(msg, msgid=None, sender=None, listid=None, in_reply_to=None):
7979
msg['Message-Id'] = msgid or make_msgid()
8080
msg['Subject'] = 'Test subject'
8181
msg['From'] = sender or 'Test Author <[email protected]>'
8282
msg['List-Id'] = listid or 'test.example.com'
83+
if in_reply_to:
84+
msg['In-Reply-To'] = in_reply_to
8385

8486
return msg
8587

8688

87-
def create_email(content, msgid=None, sender=None, listid=None):
89+
def create_email(content, msgid=None, sender=None, listid=None,
90+
in_reply_to=None):
8891
msg = MIMEText(content, _charset='us-ascii')
8992

90-
return _create_email(msg, msgid, sender, listid)
93+
return _create_email(msg, msgid, sender, listid, in_reply_to)
9194

9295

9396
def parse_mail(*args, **kwargs):
@@ -767,6 +770,34 @@ def test_tags(self):
767770
tag__name='Tested-by').count, 1)
768771

769772

773+
class ParseCommentTagsTest(PatchTest):
774+
fixtures = ['default_tags']
775+
patch_filename = '0001-add-line.patch'
776+
comment_content = ('test comment\n\n' +
777+
'Tested-by: Test User <[email protected]>\n' +
778+
'Reviewed-by: Test User <[email protected]>\n')
779+
780+
def setUp(self):
781+
project = create_project(listid='test.example.com')
782+
self.orig_diff = read_patch(self.patch_filename)
783+
email = create_email(self.orig_diff,
784+
listid=project.listid)
785+
parse_mail(email)
786+
email2 = create_email(self.comment_content,
787+
in_reply_to=email['Message-Id'])
788+
parse_mail(email2)
789+
790+
def test_tags(self):
791+
self.assertEqual(Patch.objects.count(), 1)
792+
patch = Patch.objects.all()[0]
793+
self.assertEqual(patch.patchtag_set.filter(
794+
tag__name='Acked-by').count(), 0)
795+
self.assertEqual(patch.patchtag_set.get(
796+
tag__name='Reviewed-by').count, 1)
797+
self.assertEqual(patch.patchtag_set.get(
798+
tag__name='Tested-by').count, 1)
799+
800+
770801
class SubjectTest(TestCase):
771802

772803
def test_clean_subject(self):

0 commit comments

Comments
 (0)