2016-09-29 19:05:35 +00:00
|
|
|
from unittest import skipUnless
|
|
|
|
|
2015-09-14 16:19:19 +00:00
|
|
|
from django.db import connection
|
2016-09-29 19:05:35 +00:00
|
|
|
from django.test import TestCase, mock
|
2015-09-14 16:19:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestDatabaseFeatures(TestCase):
|
|
|
|
|
|
|
|
def test_nonexistent_feature(self):
|
|
|
|
self.assertFalse(hasattr(connection.features, 'nonexistent'))
|
2016-09-29 19:05:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
@skipUnless(connection.vendor == 'mysql', 'MySQL backend tests')
|
|
|
|
class TestMySQLFeatures(TestCase):
|
|
|
|
|
|
|
|
def test_mysql_supports_transactions(self):
|
|
|
|
"""
|
|
|
|
All storage engines except MyISAM support transactions.
|
|
|
|
"""
|
|
|
|
with mock.patch('django.db.connection.features._mysql_storage_engine', 'InnoDB'):
|
|
|
|
self.assertTrue(connection.features.supports_transactions)
|
|
|
|
del connection.features.supports_transactions
|
|
|
|
with mock.patch('django.db.connection.features._mysql_storage_engine', 'MyISAM'):
|
|
|
|
self.assertFalse(connection.features.supports_transactions)
|
|
|
|
del connection.features.supports_transactions
|