]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/tests/patchparser.py
Fix django-1.6 incompatibilities
[patchwork] / apps / patchwork / tests / patchparser.py
index 523b9c0d5cf62e25ddd8c9ee8cfbac983ed3e9d9..0496a69f231e21f5e0dda86c8b247560c5a7a8ea 100644 (file)
@@ -17,9 +17,9 @@
 # along with Patchwork; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import unittest
 import os
 from email import message_from_string
+from django.test import TestCase
 from patchwork.models import Project, Person, Patch, Comment, State, \
          get_default_initial_patch_state
 from patchwork.tests.utils import read_patch, read_mail, create_email, \
@@ -31,7 +31,7 @@ except ImportError:
     # Python 2.4 compatibility
     from email.MIMEText import MIMEText
 
-class PatchTest(unittest.TestCase):
+class PatchTest(TestCase):
     default_sender = defaults.sender
     default_subject = defaults.subject
     project = defaults.project
@@ -138,7 +138,7 @@ class UpdateSigCommentTest(SignatureCommentTest):
     patch_filename = '0001-add-line.patch'
     test_comment = 'Test comment\nmore comment\n---\nUpdate: test update'
 
-class SenderEncodingTest(unittest.TestCase):
+class SenderEncodingTest(TestCase):
     sender_name = u'example user'
     sender_email = 'user@example.com'
     from_header = 'example user <user@example.com>'
@@ -204,7 +204,7 @@ class SubjectUTF8QPMultipleEncodingTest(SubjectEncodingTest):
     subject = u'test s\xfcbject'
     subject_header = 'test =?utf-8?q?s=c3=bcbject?='
 
-class SenderCorrelationTest(unittest.TestCase):
+class SenderCorrelationTest(TestCase):
     existing_sender = 'Existing Sender <existing@example.com>'
     non_existing_sender = 'Non-existing Sender <nonexisting@example.com>'
 
@@ -242,7 +242,7 @@ class SenderCorrelationTest(unittest.TestCase):
     def tearDown(self):
         self.person.delete()
 
-class MultipleProjectPatchTest(unittest.TestCase):
+class MultipleProjectPatchTest(TestCase):
     """ Test that patches sent to multiple patchwork projects are
         handled correctly """
 
@@ -306,7 +306,7 @@ class MultipleProjectPatchCommentTest(MultipleProjectPatchTest):
             # and the one we parsed in setUp()
             self.assertEquals(Comment.objects.filter(patch = patch).count(), 2)
 
-class ListIdHeaderTest(unittest.TestCase):
+class ListIdHeaderTest(TestCase):
     """ Test that we parse List-Id headers from mails correctly """
     def setUp(self):
         self.project = Project(linkname = 'test-project-1', name = 'Project 1',
@@ -392,6 +392,27 @@ class GitPullSSHUrlTest(GitPullTest):
 class GitPullHTTPUrlTest(GitPullTest):
     mail_file = '0006-git-pull-request-http.mbox'
 
+class GitRenameOnlyTest(MBoxPatchTest):
+    mail_file = '0008-git-rename.mbox'
+
+    def testGitRename(self):
+        (patch, comment) = find_content(self.project, self.mail)
+        self.assertTrue(patch is not None)
+        self.assertTrue(comment is not None)
+        self.assertEqual(patch.content.count("\nrename from "), 2)
+        self.assertEqual(patch.content.count("\nrename to "), 2)
+
+class GitRenameWithDiffTest(MBoxPatchTest):
+    mail_file = '0009-git-rename-with-diff.mbox'
+
+    def testGitRename(self):
+        (patch, comment) = find_content(self.project, self.mail)
+        self.assertTrue(patch is not None)
+        self.assertTrue(comment is not None)
+        self.assertEqual(patch.content.count("\nrename from "), 2)
+        self.assertEqual(patch.content.count("\nrename to "), 2)
+        self.assertEqual(patch.content.count('\n-a\n+b'), 1)
+
 class CVSFormatPatchTest(MBoxPatchTest):
     mail_file = '0007-cvs-format-diff.mbox'
 
@@ -401,7 +422,7 @@ class CVSFormatPatchTest(MBoxPatchTest):
         self.assertTrue(comment is not None)
         self.assertTrue(patch.content.startswith('Index'))
 
-class DelegateRequestTest(unittest.TestCase):
+class DelegateRequestTest(TestCase):
     patch_filename = '0001-add-line.patch'
     msgid = '<1@example.com>'
     invalid_delegate_email = "nobody"
@@ -446,7 +467,7 @@ class DelegateRequestTest(unittest.TestCase):
         self.p1.delete()
         self.user.delete()
 
-class InitialPatchStateTest(unittest.TestCase):
+class InitialPatchStateTest(TestCase):
     patch_filename = '0001-add-line.patch'
     msgid = '<1@example.com>'
     invalid_state_name = "Nonexistent Test State"