]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/tests/patchparser.py
parser: allow words starting with "diff" at beginning of line
[patchwork] / apps / patchwork / tests / patchparser.py
index 7013e851f835bf0130be661c06e908962b33d331..06b4e546e129fbfb3b96609c769dbeacc6091015 100644 (file)
@@ -121,6 +121,11 @@ class ListFooterTest(InlinePatchTest):
         (self.patch, self.comment) = find_content(self.project, email)
 
 
+class DiffWordInCommentTest(InlinePatchTest):
+    test_comment = 'Lines can start with words beginning in "diff"\n' + \
+                   'difficult\nDifferent'
+
+
 class UpdateCommentTest(InlinePatchTest):
     """ Test for '---\nUpdate: v2' style comments to patches. """
     patch_filename = '0001-add-line.patch'
@@ -346,13 +351,15 @@ class ListIdHeaderTest(unittest.TestCase):
     def tearDown(self):
         self.project.delete()
 
+class MBoxPatchTest(PatchTest):
+    def setUp(self):
+        self.mail = read_mail(self.mail_file, project = self.project)
 
-class GitPullTest(PatchTest):
+class GitPullTest(MBoxPatchTest):
     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)
+        (patch, comment) = find_content(self.project, self.mail)
         self.assertTrue(patch is not None)
         self.assertTrue(patch.pull_url is not None)
         self.assertTrue(patch.content is None)
@@ -361,11 +368,11 @@ class GitPullTest(PatchTest):
 class GitPullWrappedTest(GitPullTest):
     mail_file = '0002-git-pull-request-wrapped.mbox'
 
-class GitPullWithDiffTest(PatchTest):
+class GitPullWithDiffTest(MBoxPatchTest):
+    mail_file = '0003-git-pull-request-with-diff.mbox'
+
     def testGitPullWithDiff(self):
-        mail = read_mail('0003-git-pull-request-with-diff.mbox',
-                        project = self.project)
-        (patch, comment) = find_content(self.project, mail)
+        (patch, comment) = find_content(self.project, self.mail)
         self.assertTrue(patch is not None)
         self.assertEqual('git://git.kernel.org/pub/scm/linux/kernel/git/tip/' +
              'linux-2.6-tip.git x86-fixes-for-linus', patch.pull_url)
@@ -373,3 +380,21 @@ class GitPullWithDiffTest(PatchTest):
             patch.content.startswith('diff --git a/arch/x86/include/asm/smp.h'),
             patch.content)
         self.assertTrue(comment is not None)
+
+class GitPullGitSSHUrlTest(GitPullTest):
+    mail_file = '0004-git-pull-request-git+ssh.mbox'
+
+class GitPullSSHUrlTest(GitPullTest):
+    mail_file = '0005-git-pull-request-ssh.mbox'
+
+class GitPullHTTPUrlTest(GitPullTest):
+    mail_file = '0006-git-pull-request-http.mbox'
+
+class CVSFormatPatchTest(MBoxPatchTest):
+    mail_file = '0007-cvs-format-diff.mbox'
+
+    def testPatch(self):
+        (patch, comment) = find_content(self.project, self.mail)
+        self.assertTrue(patch is not None)
+        self.assertTrue(comment is not None)
+        self.assertTrue(patch.content.startswith('Index'))