Ticket #21554: tests.py

File tests.py, 1.0 KB (added by Matt, 11 years ago)
Line 
1from django import test
2from django.db import models
3
4class Person(models.Model):
5 name = models.CharField(max_length=50)
6
7class Politician(models.Model):
8 politician_id = models.AutoField(primary_key=True)
9 title = models.CharField(max_length=50)
10
11class Congressman(Person, Politician):
12 state = models.CharField(max_length=2)
13
14class Senator(Congressman):
15 pass
16
17class MultiInheritanceTest(test.TestCase):
18 def test_multiple_inheritance(self):
19 Politician.objects.create(title='Ms.')
20 Person.objects.create(name="A")
21 Person.objects.create(name="B")
22 Person.objects.create(name="C")
23
24 senator = Senator.objects.create(name='John Doe',
25 title='Maj. Leader',
26 state='TX')
27
28 #print Senator.objects.filter(politician_id=1).query
29
30 senator_copy = Senator.objects.get(politician_id=senator.politician_id)
31
32 self.assertEqual(senator.pk, senator_copy.pk)
Back to Top