from django.test import TestCase

from towel import deletion

from testapp.models import Person, EmailAddress


class ModelViewTest(TestCase):
    def test_list_view(self):
        for i in range(7):
            p = Person.objects.create(family_name='Family %r' % i)

        # paginate_by=5
        self.assertContains(self.client.get('/persons/'),
            'name="batch_', 5)
        self.assertContains(self.client.get('/persons/?page=2'),
            'name="batch_', 2)

        self.assertContains(self.client.get(p.get_absolute_url()),
            'Family 6')
        self.assertEqual(self.client.get('/persons/0/').status_code, 404)
        self.assertEqual(self.client.get('/persons/a/').status_code, 404)

@@ -690,28 +690,607 @@
 sons/a/').status_code, 404)%0A
+%0A    def test_crud(self):%0A        self.assertContains(self.client.get('/persons/add/'), '%3Cform', 1)%0A        self.assertEqual(self.client.post('/persons/add/', %7B%7D).status_code,%0A            200)%0A        response = self.client.post('/persons/add/', %7B%0A            'family_name': 'Blub',%0A            'given_name': 'Blab',%0A            'created': '2013-01-01 01:00:00',%0A            %7D)%0A        person = Person.objects.get()%0A        self.assertRedirects(response, person.get_absolute_url())%0A        self.assertContains(self.client.get(person.get_absolute_url()),%0A            'Blab Blub')%0A

Add tests for adding stuff through the ModelView