+class ListIdHeaderTest(unittest.TestCase):
+ """ Test that we parse List-Id headers from mails correctly """
+ def setUp(self):
+ self.project = Project(linkname = 'test-project-1', name = 'Project 1',
+ listid = '1.example.com', listemail='1@example.com')
+ self.project.save()
+
+ def testNoListId(self):
+ email = MIMEText('')
+ project = find_project(email)
+ self.assertEquals(project, None)
+
+ def testBlankListId(self):
+ email = MIMEText('')
+ email['List-Id'] = ''
+ project = find_project(email)
+ self.assertEquals(project, None)
+
+ def testWhitespaceListId(self):
+ email = MIMEText('')
+ email['List-Id'] = ' '
+ project = find_project(email)
+ self.assertEquals(project, None)
+
+ def testSubstringListId(self):
+ email = MIMEText('')
+ email['List-Id'] = 'example.com'
+ project = find_project(email)
+ self.assertEquals(project, None)
+
+ def testShortListId(self):
+ """ Some mailing lists have List-Id headers in short formats, where it
+ is only the list ID itself (without enclosing angle-brackets). """
+ email = MIMEText('')
+ email['List-Id'] = self.project.listid
+ project = find_project(email)
+ self.assertEquals(project, self.project)
+
+ def testLongListId(self):
+ email = MIMEText('')
+ email['List-Id'] = 'Test text <%s>' % self.project.listid
+ project = find_project(email)
+ self.assertEquals(project, self.project)
+
+ def tearDown(self):
+ self.project.delete()
+
+
+class GitPullTest(PatchTest):
+ mail_file = '0001-git-pull-request.mbox'
+
+ def testGitPullRequest(self):
+ mail = read_mail(self.mail_file, project = self.project)
+ (patch, comment) = find_content(self.project, mail)
+ self.assertTrue(patch is not None)
+ self.assertTrue(patch.pull_url is not None)
+ self.assertTrue(patch.content is None)
+ self.assertTrue(comment is not None)
+
+class GitPullWrappedTest(GitPullTest):
+ mail_file = '0002-git-pull-request-wrapped.mbox'