]> git.ozlabs.org Git - patchwork/commitdiff
tests/updates: Add delegate clear test
authorJeremy Kerr <jk@ozlabs.org>
Fri, 3 Sep 2010 04:40:43 +0000 (12:40 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 3 Sep 2010 04:44:59 +0000 (12:44 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/tests/updates.py

index 9a92ba0f989248205b0ed1f247f748ac61517521..e5f175c37757f30062c1dee4fb164385dc267634 100644 (file)
@@ -69,17 +69,17 @@ class MultipleUpdateTest(TestCase):
         self.assertEquals( \
                 [Patch.objects.get(pk = p.pk).state for p in self.patches],
                 orig_states)
-        self.assertEquals(response.context['errors'],
-                    ['The submitted form data was invalid'])
+        self.assertFormError(response, 'patchform', 'state',
+                    'Select a valid choice. That choice is not one ' + \
+                        'of the available choices.')
 
-    def testDelegateChange(self):
-        delegate = create_maintainer(defaults.project)
+    def _testDelegateChange(self, delegate_str):
         data = {'action':   'Update',
                 'project':  str(defaults.project.id),
                 'form':     'patchlistform',
                 'archived': '*',
                 'state':    '*',
-                'delegate': str(delegate.pk),
+                'delegate': delegate_str
         }
         for patch in self.patches:
             data['patch_id:%d' % patch.id] = 'checked'
@@ -88,9 +88,19 @@ class MultipleUpdateTest(TestCase):
                 args = [defaults.project.linkname])
         response = self.client.post(url, data)
         self.failUnlessEqual(response.status_code, 200)
+        return response
+
+    def testDelegateChangeValid(self):
+        delegate = create_maintainer(defaults.project)
+        response = self._testDelegateChange(str(delegate.pk))
         for patch in [Patch.objects.get(pk = p.pk) for p in self.patches]:
             self.assertEquals(patch.delegate, delegate)
 
+    def testDelegateClear(self):
+        response = self._testDelegateChange('')
+        for patch in [Patch.objects.get(pk = p.pk) for p in self.patches]:
+            self.assertEquals(patch.delegate, None)
+
     def tearDown(self):
         for p in self.patches:
             p.delete()