1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

[soc2009/multidb] Fix a number of tests that were looking at settings.DATABASE_ENGINE, which has been deprecated in favor of the DATABASES interface

git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11406 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Alex Gaynor 2009-08-06 00:27:53 +00:00
parent e2fecde4a9
commit 8ad4ea7b04
4 changed files with 10 additions and 11 deletions

View File

@ -16,7 +16,7 @@ try:
except NameError:
from django.utils.itercompat import sorted
from django.db import models
from django.db import models, DEFAULT_DB_ALIAS
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
@ -365,7 +365,7 @@ from django.conf import settings
building_docs = getattr(settings, 'BUILDING_DOCS', False)
if building_docs or settings.DATABASE_ENGINE == 'postgresql':
if building_docs or settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] == 'postgresql':
__test__['API_TESTS'] += """
# In PostgreSQL, microsecond-level precision is available.
>>> a9 = Article(headline='Article 9', pub_date=datetime(2005, 7, 31, 12, 30, 45, 180))
@ -374,7 +374,7 @@ if building_docs or settings.DATABASE_ENGINE == 'postgresql':
datetime.datetime(2005, 7, 31, 12, 30, 45, 180)
"""
if building_docs or settings.DATABASE_ENGINE == 'mysql':
if building_docs or settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] == 'mysql':
__test__['API_TESTS'] += """
# In MySQL, microsecond-level precision isn't available. You'll lose
# microsecond-level precision once the data is saved.

View File

@ -7,7 +7,7 @@ this behavior by explicitly adding ``primary_key=True`` to a field.
"""
from django.conf import settings
from django.db import models, transaction, IntegrityError
from django.db import models, transaction, IntegrityError, DEFAULT_DB_ALIAS
from fields import MyAutoField
@ -156,7 +156,7 @@ True
# SQLite lets objects be saved with an empty primary key, even though an
# integer is expected. So we can't check for an error being raised in that case
# for SQLite. Remove it from the suite for this next bit.
if settings.DATABASE_ENGINE != 'sqlite3':
if settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] != 'sqlite3':
__test__["API_TESTS"] += """
# The primary key must be specified, so an error is raised if you try to create
# an object without it.

View File

@ -2,7 +2,7 @@
import datetime
from django.conf import settings
from django.db import models
from django.db import models, DEFAULT_DB_ALIAS
from django.utils import tzinfo
CHOICES = (
@ -149,7 +149,7 @@ datetime.datetime(2000, 1, 1, 6, 1, 1)
"""}
if settings.DATABASE_ENGINE not in ("mysql", "oracle"):
if settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] not in ("mysql", "oracle"):
__test__["timezone-tests"] = """
# Saving an updating with timezone-aware datetime Python objects. Regression
# test for #10443.
@ -167,4 +167,3 @@ if settings.DATABASE_ENGINE not in ("mysql", "oracle"):
1
"""

View File

@ -7,7 +7,7 @@ import pickle
import sys
from django.conf import settings
from django.db import models
from django.db import models, DEFAULT_DB_ALIAS
from django.db.models.query import Q, ITER_CHUNK_SIZE
# Python 2.3 doesn't have sorted()
@ -1209,13 +1209,13 @@ FieldError: Infinite loop caused by ordering.
# In Oracle, we expect a null CharField to return u'' instead of None.
if settings.DATABASE_ENGINE == "oracle":
if settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] == "oracle":
__test__["API_TESTS"] = __test__["API_TESTS"].replace("<NONE_OR_EMPTY_UNICODE>", "u''")
else:
__test__["API_TESTS"] = __test__["API_TESTS"].replace("<NONE_OR_EMPTY_UNICODE>", "None")
if settings.DATABASE_ENGINE == "mysql":
if settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] == "mysql":
__test__["API_TESTS"] += """
When grouping without specifying ordering, we add an explicit "ORDER BY NULL"
portion in MySQL to prevent unnecessary sorting.