]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/tests/patchparser.py
tests: add abstract mbox parsing test
[patchwork] / apps / patchwork / tests / patchparser.py
index 1135a0a57b9f9b795d2d882b76e5bdb89cf5cae6..296da5ffe8147c53388d25bc177ced80b19a68f2 100644 (file)
@@ -346,13 +346,42 @@ 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(MBoxPatchTest):
+    mail_file = '0001-git-pull-request.mbox'
 
-class GitPullTest(PatchTest):
     def testGitPullRequest(self):
-        mail = read_mail('0001-git-pull-request.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.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'
+
+class GitPullWithDiffTest(MBoxPatchTest):
+    mail_file = '0003-git-pull-request-with-diff.mbox'
+
+    def testGitPullWithDiff(self):
+        (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)
+        self.assertTrue(
+            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'
+