summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Pellerin <jpellerin@gmail.com>2006-07-07 21:31:16 +0000
committerJason Pellerin <jpellerin@gmail.com>2006-07-07 21:31:16 +0000
commit60947322a582e4bc3f07622024ef7e2d470b0d68 (patch)
treeb672228ccfd33fd10bf6ad1068df6102ce3fa22a
parentc1087076b4fb1165a0f8ebda73ca892cebcf9c26 (diff)
[multi-db] Updated tests to expect pendings in dict format instead of
list. git-svn-id: http://code.djangoproject.com/svn/django/branches/multiple-db-support@3293 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--tests/modeltests/multiple_databases/models.py3
-rw-r--r--tests/othertests/ansi_sql.py20
-rw-r--r--tests/othertests/manager_schema_manipulation.py21
3 files changed, 26 insertions, 18 deletions
diff --git a/tests/modeltests/multiple_databases/models.py b/tests/modeltests/multiple_databases/models.py
index 9c974ef7bd..b9a1939d41 100644
--- a/tests/modeltests/multiple_databases/models.py
+++ b/tests/modeltests/multiple_databases/models.py
@@ -131,11 +131,12 @@ False
>>> artists[0]._meta.connection.settings == connections['django_test_db_a'].settings
True
-# When not using transaction management, model save will commit only
+# When transactions are not managed, model save will commit only
# for the model's connection.
>>> from django.db import transaction
>>> transaction.enter_transaction_management()
+>>> transaction.managed(False)
>>> a = Artist(name="Joan Miro", alive=False)
>>> w = Widget(code="99rbln", weight=1)
>>> a.save()
diff --git a/tests/othertests/ansi_sql.py b/tests/othertests/ansi_sql.py
index 7dfe1165b2..de12eaf590 100644
--- a/tests/othertests/ansi_sql.py
+++ b/tests/othertests/ansi_sql.py
@@ -1,3 +1,7 @@
+# For Python 2.3
+if not hasattr(__builtins__, 'set'):
+ from sets import Set as set
+
"""
>>> from django.db import models
>>> from django.db.backends.ansi import sql
@@ -33,30 +37,30 @@
([BoundStatement('CREATE TABLE "ansi_sql_car" (...);')], [])
>>> builder.models_already_seen
[<class 'othertests.ansi_sql.Car'>]
->>> builder.models_already_seen = []
+>>> builder.models_already_seen = set()
# test that styles are used
>>> builder.get_create_table(Car, style=mockstyle())
([BoundStatement('SQL_KEYWORD(CREATE TABLE) SQL_TABLE("ansi_sql_car") (...SQL_FIELD("id")...);')], [])
# test pending relationships
->>> builder.models_already_seen = []
+>>> builder.models_already_seen = set()
>>> real_cnst = Mod._meta.connection_info.backend.supports_constraints
>>> Mod._meta.connection_info.backend.supports_constraints = True
>>> builder.get_create_table(Mod)
-([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL,...);')], [BoundStatement('ALTER TABLE "ansi_sql_mod" ADD CONSTRAINT ... FOREIGN KEY ("car_id") REFERENCES "ansi_sql_car" ("id");')])
->>> builder.models_already_seen = []
+([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL,...);')], {<class 'othertests.ansi_sql.Car'>: [BoundStatement('ALTER TABLE "ansi_sql_mod" ADD CONSTRAINT ... FOREIGN KEY ("car_id") REFERENCES "ansi_sql_car" ("id");')]})
+>>> builder.models_already_seen = set()
>>> builder.get_create_table(Car)
-([BoundStatement('CREATE TABLE "ansi_sql_car" (...);')], [])
+([BoundStatement('CREATE TABLE "ansi_sql_car" (...);')], {})
>>> builder.get_create_table(Mod)
-([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL REFERENCES "ansi_sql_car" ("id"),...);')], [])
+([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL REFERENCES "ansi_sql_car" ("id"),...);')], {})
>>> Mod._meta.connection_info.backend.supports_constraints = real_cnst
# test many-many
>>> builder.get_create_table(Collector)
-([BoundStatement('CREATE TABLE "ansi_sql_collector" (...);')], [])
+([BoundStatement('CREATE TABLE "ansi_sql_collector" (...);')], {})
>>> builder.get_create_many_to_many(Collector)
-[BoundStatement('CREATE TABLE "ansi_sql_collector_cars" (...);')]
+{<class 'othertests.ansi_sql.Car'>: [BoundStatement('CREATE TABLE "ansi_sql_collector_cars" (...);')]}
# test indexes
>>> builder.get_create_indexes(Car)
diff --git a/tests/othertests/manager_schema_manipulation.py b/tests/othertests/manager_schema_manipulation.py
index e3c8fb37b9..1b69083e0e 100644
--- a/tests/othertests/manager_schema_manipulation.py
+++ b/tests/othertests/manager_schema_manipulation.py
@@ -87,11 +87,11 @@
# use the default connection or a named connection.
>>> DA.objects.install()
-[]
+{}
>>> QA.objects.install()
-[]
+{}
>>> QB.objects.install()
-[]
+{}
>>> DA.objects.all()
[]
>>> list(QA.objects.all())
@@ -107,25 +107,28 @@
# statements that could not be executed because (for instance) they are
# meant to establish foreign key relationships to tables that don't
# exist. These are bound to the model's connection and should
-# be executed after all models in the app have been installed.
+# be executed after all models in the app have been installed. The pending
+# statments are returned as a dict keyed by the model which must be installed
+# before the pending statements can be installed.
# NOTE: pretend db supports constraints for this test
>>> real_cnst = PA._meta.connection_info.backend.supports_constraints
>>> PA._meta.connection_info.backend.supports_constraints = True
>>> result = PA.objects.install()
>>> result
-[BoundStatement('ALTER TABLE "othertests_pa" ADD CONSTRAINT "c_id_referencing_othertests_pc_id" FOREIGN KEY ("c_id") REFERENCES "othertests_pc" ("id");')]
+{<class 'othertests.manager_schema_manipulation.PC'>: [BoundStatement('ALTER TABLE "othertests_pa" ADD CONSTRAINT "c_id_referencing_othertests_pc_id" FOREIGN KEY ("c_id") REFERENCES "othertests_pc" ("id");')]}
# NOTE: restore real constraint flag
>>> PA._meta.connection_info.backend.supports_constraints = real_cnst
-# Models with many-many relationships will also have pending statement
+# Models with many-many relationships may also have pending statement
# lists. Like other pending statements, these should be executed after
-# all models in the app have been installed.
+# all models in the app have been installed. If the related table's model
+# has already been created, then there will be no pending list.
>>> QC.objects.install()
-[]
+{}
>>> QD.objects.install()
-[BoundStatement('CREATE TABLE "othertests_qd_qcs" (...);')]
+{}
"""