1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #33379 -- Added minimum database version checks.

Thanks Tim Graham for the review.
This commit is contained in:
Hasan Ramezani
2021-12-27 19:04:59 +01:00
committed by Mariusz Felisiak
parent 737542390a
commit 9ac3ef59f9
16 changed files with 166 additions and 41 deletions

View File

@@ -1,8 +1,9 @@
import unittest
from contextlib import contextmanager
from unittest import mock
from django.core.exceptions import ImproperlyConfigured
from django.db import connection
from django.db import NotSupportedError, connection
from django.test import TestCase, override_settings
@@ -99,3 +100,19 @@ class IsolationLevelTests(TestCase):
)
with self.assertRaisesMessage(ImproperlyConfigured, msg):
new_connection.cursor()
@unittest.skipUnless(connection.vendor == "mysql", "MySQL tests")
class Tests(TestCase):
@mock.patch.object(connection, "get_database_version")
def test_check_database_version_supported(self, mocked_get_database_version):
if connection.mysql_is_mariadb:
mocked_get_database_version.return_value = (10, 1)
msg = "MariaDB 10.2 or later is required (found 10.1)."
else:
mocked_get_database_version.return_value = (5, 6)
msg = "MySQL 5.7 or later is required (found 5.6)."
with self.assertRaisesMessage(NotSupportedError, msg):
connection.check_database_version_supported()
self.assertTrue(mocked_get_database_version.called)