summaryrefslogtreecommitdiff
path: root/tests/check_framework
diff options
context:
space:
mode:
Diffstat (limited to 'tests/check_framework')
-rw-r--r--tests/check_framework/test_database.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/check_framework/test_database.py b/tests/check_framework/test_database.py
index 73edd6234c..594f4ccee6 100644
--- a/tests/check_framework/test_database.py
+++ b/tests/check_framework/test_database.py
@@ -31,3 +31,28 @@ class DatabaseCheckTests(TestCase):
with mock.patch('django.db.backends.base.validation.BaseDatabaseValidation.check') as mocked_check:
run_checks(tags=[Tags.database])
self.assertTrue(mocked_check.called)
+
+ @unittest.skipUnless(connection.vendor == 'mysql', 'Test only for MySQL')
+ def test_mysql_strict_mode(self):
+ good_sql_modes = [
+ 'STRICT_TRANS_TABLES,STRICT_ALL_TABLES',
+ 'STRICT_TRANS_TABLES',
+ 'STRICT_ALL_TABLES',
+ ]
+ for response in good_sql_modes:
+ with mock.patch(
+ 'django.db.backends.utils.CursorWrapper.fetchone', create=True,
+ return_value=(response,)
+ ):
+ self.assertEqual(self.func(None), [])
+
+ bad_sql_modes = ['', 'WHATEVER']
+ for response in bad_sql_modes:
+ with mock.patch(
+ 'django.db.backends.utils.CursorWrapper.fetchone', create=True,
+ return_value=(response,)
+ ):
+ # One warning for each database alias
+ result = self.func(None)
+ self.assertEqual(len(result), 2)
+ self.assertEqual([r.id for r in result], ['mysql.W002', 'mysql.W002'])