тест кейс для одного набора урлов

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class ProviderTestCase(TestCase):
def testList(self):
self.failUnlessEqual(self.client.get('/cmf/providers/').status_code, 200)
def testAdd(self):
self.failUnlessEqual(self.client.get('/cmf/providers/add/').status_code, 200)
self.assertContains(self.client.post('/cmf/providers/add/'), 'class="errorlist"')
self.assertRedirects(self.client.post('/cmf/providers/add/', {'title':'TestProvider'}), '/cmf/providers/')
def testDelete(self):
pk = Provider.objects.create(title="TestProvider").pk
self.assertContains(self.client.get('/cmf/providers/%d/delete/' % pk), 'class="warning"')
self.assertRedirects(self.client.post('/cmf/providers/%d/delete/' % pk), '/cmf/providers/')
self.assertRaises(Provider.DoesNotExist, lambda: Provider.objects.get(title="TestProvider"))
def testEdit(self):
pk = Provider.objects.create(title="TestProvider").pk
self.failUnlessEqual(self.client.get('/cmf/providers/%d/' % pk).status_code, 200)
self.assertContains(self.client.post('/cmf/providers/%d/' % pk), 'class="errorlist"')
self.assertRedirects(self.client.post('/cmf/providers/%d/' % pk, {'title':'ModifiedTestProvider'}),
'/cmf/providers/')
self.failUnlessEqual(Provider.objects.get(pk=pk).title, 'ModifiedTestProvider')