PageRenderTime 92ms CodeModel.GetById 41ms app.highlight 2ms RepoModel.GetById 48ms app.codeStats 0ms

/tests/modeltests/save_delete_hooks/tests.py

https://code.google.com/p/mango-py/
Python | 30 lines | 25 code | 5 blank | 0 comment | 0 complexity | fdd5b7deb5be6cc6d1d1f439b7cdddbf MD5 | raw file
 1from django.test import TestCase
 2
 3from models import Person
 4
 5
 6class SaveDeleteHookTests(TestCase):
 7    def test_basic(self):
 8        p = Person(first_name="John", last_name="Smith")
 9        self.assertEqual(p.data, [])
10        p.save()
11        self.assertEqual(p.data, [
12            "Before save",
13            "After save",
14        ])
15
16        self.assertQuerysetEqual(
17            Person.objects.all(), [
18                "John Smith",
19            ],
20            unicode
21        )
22
23        p.delete()
24        self.assertEqual(p.data, [
25            "Before save",
26            "After save",
27            "Before deletion",
28            "After deletion",
29        ])
30        self.assertQuerysetEqual(Person.objects.all(), [])