From fb60b3f6d9e7a5fcd2dc9fd83893c03118a6e533 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Fri, 3 Sep 2010 12:40:43 +0800 Subject: tests/updates: Add delegate clear test Signed-off-by: Jeremy Kerr --- apps/patchwork/tests/updates.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'apps/patchwork/tests') diff --git a/apps/patchwork/tests/updates.py b/apps/patchwork/tests/updates.py index 9a92ba0..e5f175c 100644 --- a/apps/patchwork/tests/updates.py +++ b/apps/patchwork/tests/updates.py @@ -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() -- cgit v1.2.3