1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

[soc2009/multidb] Added tests to ensure that objects aren't being created before they are supposed to be, which would indicate we weren't creating objects in the right DB.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11076 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2009-06-19 00:29:18 +00:00
parent 64eec4a120
commit 903ff126b0

View File

@ -28,6 +28,8 @@ class ConnectionHandlerTestCase(TestCase):
class QueryTestCase(TestCase): class QueryTestCase(TestCase):
def test_basic_queries(self): def test_basic_queries(self):
for db in connections: for db in connections:
self.assertRaises(Book.DoesNotExist,
lambda: Book.objects.using(db).get(title="Dive into Python"))
Book.objects.using(db).create(title="Dive into Python", Book.objects.using(db).create(title="Dive into Python",
published=datetime.date(2009, 5, 4)) published=datetime.date(2009, 5, 4))
@ -39,6 +41,8 @@ class QueryTestCase(TestCase):
self.assertEqual(books[0].published, datetime.date(2009, 5, 4)) self.assertEqual(books[0].published, datetime.date(2009, 5, 4))
for db in connections: for db in connections:
self.assertRaises(Book.DoesNotExist,
lambda: Book.objects.using(db).get(title="Pro Django"))
book = Book(title="Pro Django", published=datetime.date(2008, 12, 16)) book = Book(title="Pro Django", published=datetime.date(2008, 12, 16))
book.save(using=db) book.save(using=db)