mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[soc2009/multidb] Fix the remaining tests that were depending on the out of date setting.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/multidb@11407 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Unit and doctests for specific database backends.
|
||||
import unittest
|
||||
from django.db import connection
|
||||
from django.db import connection, DEFAULT_DB_ALIAS
|
||||
from django.db.backends.signals import connection_created
|
||||
from django.conf import settings
|
||||
|
||||
@@ -10,7 +10,7 @@ class Callproc(unittest.TestCase):
|
||||
def test_dbms_session(self):
|
||||
# If the backend is Oracle, test that we can call a standard
|
||||
# stored procedure through our cursor wrapper.
|
||||
if settings.DATABASE_ENGINE == 'oracle':
|
||||
if settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] == 'oracle':
|
||||
cursor = connection.cursor()
|
||||
cursor.callproc('DBMS_SESSION.SET_IDENTIFIER',
|
||||
['_django_testing!',])
|
||||
@@ -33,6 +33,21 @@ class LongString(unittest.TestCase):
|
||||
c.execute('DROP TABLE ltext')
|
||||
self.assertEquals(long_str, row[0].read())
|
||||
|
||||
class LongString(unittest.TestCase):
|
||||
|
||||
def test_long_string(self):
|
||||
# If the backend is Oracle, test that we can save a text longer
|
||||
# than 4000 chars and read it properly
|
||||
if settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] == 'oracle':
|
||||
c = connection.cursor()
|
||||
c.execute('CREATE TABLE ltext ("TEXT" NCLOB)')
|
||||
long_str = ''.join([unicode(x) for x in xrange(4000)])
|
||||
c.execute('INSERT INTO ltext VALUES (%s)',[long_str])
|
||||
c.execute('SELECT text FROM ltext')
|
||||
row = c.fetchone()
|
||||
c.execute('DROP TABLE ltext')
|
||||
self.assertEquals(long_str, row[0].read())
|
||||
|
||||
def connection_created_test(sender, **kwargs):
|
||||
print 'connection_created signal'
|
||||
|
||||
@@ -63,7 +78,7 @@ __test__ = {'API_TESTS': """
|
||||
# Unfortunately with sqlite3 the in-memory test database cannot be
|
||||
# closed, and so it cannot be re-opened during testing, and so we
|
||||
# sadly disable this test for now.
|
||||
if settings.DATABASE_ENGINE != 'sqlite3':
|
||||
if settings.DATABASES[DEFAULT_DB_ALIAS]['DATABASE_ENGINE'] != 'sqlite3':
|
||||
__test__['API_TESTS'] += """
|
||||
>>> connection_created.connect(connection_created_test)
|
||||
>>> connection.close() # Ensure the connection is closed
|
||||
|
||||
Reference in New Issue
Block a user