2009-01-16 22:23:58 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-03-29 23:15:58 +00:00
|
|
|
# Unit and doctests for specific database backends.
|
2009-01-16 22:23:58 +00:00
|
|
|
import unittest
|
|
|
|
from django.db import connection
|
2009-03-29 23:15:58 +00:00
|
|
|
from django.db.backends.signals import connection_created
|
2009-01-16 22:23:58 +00:00
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
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':
|
|
|
|
cursor = connection.cursor()
|
|
|
|
cursor.callproc('DBMS_SESSION.SET_IDENTIFIER',
|
|
|
|
['_django_testing!',])
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
|
2009-03-29 23:15:58 +00:00
|
|
|
def connection_created_test(sender, **kwargs):
|
|
|
|
print 'connection_created signal'
|
|
|
|
|
|
|
|
__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':
|
|
|
|
__test__['API_TESTS'] += """
|
|
|
|
>>> connection_created.connect(connection_created_test)
|
|
|
|
>>> connection.close() # Ensure the connection is closed
|
|
|
|
>>> cursor = connection.cursor()
|
|
|
|
connection_created signal
|
|
|
|
>>> connection_created.disconnect(connection_created_test)
|
|
|
|
>>> cursor = connection.cursor()
|
|
|
|
"""
|
2009-01-16 22:23:58 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|