1
0
mirror of https://github.com/django/django.git synced 2025-07-06 02:39:12 +00:00

[multi-db] Fixed broken tests.

git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3382 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jason Pellerin 2006-07-19 16:40:16 +00:00
parent 89ec26a585
commit cf48f3cc82

View File

@ -75,9 +75,14 @@ class Vehicle(models.Model):
API_TESTS = """ API_TESTS = """
# See what connections are defined. django.db.connections acts like a dict. # See what connections are defined. django.db.connections acts like a dict.
>>> from django.db import connection, connections >>> from django.db import connection, connections, _default
>>> from django.conf import settings >>> from django.conf import settings
>>> connections.keys()
# The default connection is in there, but let's ignore it
>>> non_default = connections.keys()
>>> non_default.remove(_default)
>>> non_default
['django_test_db_a', 'django_test_db_b'] ['django_test_db_a', 'django_test_db_b']
# Each connection references its settings # Each connection references its settings
@ -95,15 +100,15 @@ Traceback (most recent call last):
ImproperlyConfigured: No database connection 'bad' has been configured ImproperlyConfigured: No database connection 'bad' has been configured
# Models can access their connections through their managers # Models can access their connections through their managers
>>> Artist.objects.db == connections['django_test_db_a'] >>> Artist.objects.db is connections['django_test_db_a']
True True
>>> Widget.objects.db == connections['django_test_db_b'] >>> Widget.objects.db is connections['django_test_db_b']
True True
>>> Vehicle.objects.db.connection == connection >>> Vehicle.objects.db.connection.settings.DATABASE_NAME == connection.settings.DATABASE_NAME
True True
>>> Artist.objects.db == Widget.objects.db >>> Artist.objects.db is Widget.objects.db
False False
>>> Artist.objects.db.connection == Vehicle.objects.db.connection >>> Artist.objects.db.connection is Vehicle.objects.db.connection
False False
>>> a = Artist(name="Paul Klee", alive=False) >>> a = Artist(name="Paul Klee", alive=False)
>>> a.save() >>> a.save()