@@ -529,11 +529,17 @@ class DelegateRequestTest(TestCase):
self.p1.delete()
self.user.delete()
-class InitialPatchStateTest(TestCase):
+class MailFromPatchTest(TestCase):
fixtures = ['default_states']
patch_filename = '0001-add-line.patch'
msgid = '<1@example.com>'
- invalid_state_name = "Nonexistent Test State"
+
+ def get_email(self):
+ email = create_email(self.patch)
+ del email['List-ID']
+ email['List-ID'] = '<' + self.p1.listid + '>'
+ email['Message-Id'] = self.msgid
+ return email
def setUp(self):
self.patch = read_patch(self.patch_filename)
@@ -541,16 +547,19 @@ class InitialPatchStateTest(TestCase):
self.p1 = Project(linkname = 'test-project-1', name = 'Project 1',
listid = '1.example.com', listemail='1@example.com')
self.p1.save()
+
+ def tearDown(self):
+ self.p1.delete()
+ self.user.delete()
+
+class InitialPatchStateTest(MailFromPatchTest):
+ invalid_state_name = "Nonexistent Test State"
+
+ def setUp(self):
+ super(InitialPatchStateTest, self).setUp()
self.default_state = get_default_initial_patch_state()
self.nondefault_state = State.objects.get(name="Accepted")
- def get_email(self):
- email = create_email(self.patch)
- del email['List-ID']
- email['List-ID'] = '<' + self.p1.listid + '>'
- email['Message-Id'] = self.msgid
- return email
-
def _assertState(self, state):
query = Patch.objects.filter(project=self.p1)
self.assertEquals(query.count(), 1)
@@ -586,10 +595,6 @@ class InitialPatchStateTest(TestCase):
parse_mail(email)
self._assertState(self.default_state)
- def tearDown(self):
- self.p1.delete()
- self.user.delete()
-
class ParseInitialTagsTest(PatchTest):
patch_filename = '0001-add-line.patch'
test_comment = ('test comment\n\n' +
We're going to write a test that needs to craft a mail and InitialPatchStateTest was already doing what we wanted. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com> --- patchwork/tests/test_patchparser.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)