mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +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:
parent
e2fecde4a9
commit
8ad4ea7b04
@ -16,7 +16,7 @@ try:
|
|||||||
except NameError:
|
except NameError:
|
||||||
from django.utils.itercompat import sorted
|
from django.utils.itercompat import sorted
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models, DEFAULT_DB_ALIAS
|
||||||
|
|
||||||
class Article(models.Model):
|
class Article(models.Model):
|
||||||
headline = models.CharField(max_length=100, default='Default headline')
|
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)
|
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'] += """
|
__test__['API_TESTS'] += """
|
||||||
# In PostgreSQL, microsecond-level precision is available.
|
# In PostgreSQL, microsecond-level precision is available.
|
||||||
>>> a9 = Article(headline='Article 9', pub_date=datetime(2005, 7, 31, 12, 30, 45, 180))
|
>>> 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)
|
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'] += """
|
__test__['API_TESTS'] += """
|
||||||
# In MySQL, microsecond-level precision isn't available. You'll lose
|
# In MySQL, microsecond-level precision isn't available. You'll lose
|
||||||
# microsecond-level precision once the data is saved.
|
# microsecond-level precision once the data is saved.
|
||||||
|
@ -7,7 +7,7 @@ this behavior by explicitly adding ``primary_key=True`` to a field.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django.conf import settings
|
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
|
from fields import MyAutoField
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ True
|
|||||||
# SQLite lets objects be saved with an empty primary key, even though an
|
# 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
|
# 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.
|
# 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"] += """
|
__test__["API_TESTS"] += """
|
||||||
# The primary key must be specified, so an error is raised if you try to create
|
# The primary key must be specified, so an error is raised if you try to create
|
||||||
# an object without it.
|
# an object without it.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models, DEFAULT_DB_ALIAS
|
||||||
from django.utils import tzinfo
|
from django.utils import tzinfo
|
||||||
|
|
||||||
CHOICES = (
|
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"] = """
|
__test__["timezone-tests"] = """
|
||||||
# Saving an updating with timezone-aware datetime Python objects. Regression
|
# Saving an updating with timezone-aware datetime Python objects. Regression
|
||||||
# test for #10443.
|
# test for #10443.
|
||||||
@ -167,4 +167,3 @@ if settings.DATABASE_ENGINE not in ("mysql", "oracle"):
|
|||||||
1
|
1
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import pickle
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.conf import settings
|
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
|
from django.db.models.query import Q, ITER_CHUNK_SIZE
|
||||||
|
|
||||||
# Python 2.3 doesn't have sorted()
|
# 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.
|
# 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''")
|
__test__["API_TESTS"] = __test__["API_TESTS"].replace("<NONE_OR_EMPTY_UNICODE>", "u''")
|
||||||
else:
|
else:
|
||||||
__test__["API_TESTS"] = __test__["API_TESTS"].replace("<NONE_OR_EMPTY_UNICODE>", "None")
|
__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"] += """
|
__test__["API_TESTS"] += """
|
||||||
When grouping without specifying ordering, we add an explicit "ORDER BY NULL"
|
When grouping without specifying ordering, we add an explicit "ORDER BY NULL"
|
||||||
portion in MySQL to prevent unnecessary sorting.
|
portion in MySQL to prevent unnecessary sorting.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user