1 | @@ -1116,6 +1123,23 @@ class RouterTestCase(TestCase):
|
---|
2 | self.assertEqual(Book.objects.using('default').count(), 1)
|
---|
3 | self.assertEqual(Book.objects.using('other').count(), 1)
|
---|
4 |
|
---|
5 | + book, created = Book.objects.get_or_create(title="Two Scoops of Django",
|
---|
6 | + defaults={'published':datetime.date(2013, 4, 16)})
|
---|
7 | + self.assertTrue(created)
|
---|
8 | +
|
---|
9 | + # Check the head count of objects
|
---|
10 | + self.assertEqual(Book.objects.using('default').count(), 2)
|
---|
11 | + self.assertEqual(Book.objects.using('other').count(), 1)
|
---|
12 | + # If a database isn't specified, the read database is used
|
---|
13 | + self.assertEqual(Book.objects.count(), 1)
|
---|
14 | +
|
---|
15 | + Book.objects.all().delete()
|
---|
16 | +
|
---|
17 | + # Check the head count of objects
|
---|
18 | + self.assertEqual(Book.objects.using('default').count(), 0)
|
---|
19 | + self.assertEqual(Book.objects.using('other').count(), 1)
|
---|
20 |
|
---|