1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

[soc2009/multidb] Added tests for using foreign keys across multipled databases, ManyToMany tests will come after the merger of my many-to-many refactor work.

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11425 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor
2009-08-09 22:03:24 +00:00
parent 1cbe183ff7
commit 0d62f50271
2 changed files with 14 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ from django.conf import settings
from django.db import connections
from django.test import TestCase
from models import Book
from models import Book, Author
try:
# we only have these models if the user is using multi-db, it's safe the
@@ -79,11 +79,14 @@ class PickleQuerySetTestCase(TestCase):
if len(settings.DATABASES) > 1:
class MetaUsingTestCase(TestCase):
def test_meta_using_queries(self):
a = Article.objects.create(title="Django Rules!")
auth = Author.objects.create(name="Zed Shaw")
a = Article.objects.create(title="Django Rules!", author=auth)
self.assertEqual(Article.objects.get(title="Django Rules!"), a)
for db in connections:
if db == article_using:
self.assertEqual(Article.objects.using(db).get(title="Django Rules!"), a)
a1 = Article.objects.using(db).get(title="Django Rules!")
self.assertEqual(a1, a)
self.assertEqual(a1.author, auth)
else:
self.assertRaises(Article.DoesNotExist,
lambda: Article.objects.using(db).get(title="Django Rules!"))