diff options
| author | Yann Sionneau <yann@sionneau.net> | 2019-07-14 12:32:20 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-16 07:25:43 +0200 |
| commit | e47b8293a793653bd7df795c1d9f0381f3f22cf7 (patch) | |
| tree | 393a2c89f8b23e7f5e86052bd56400734f9e1c0b /tests | |
| parent | c1b94e32fb3df25d72b5e9973da7928dddbc3a2e (diff) | |
Fixed #30636 -- Fixed options ordering when cloning test database on MySQL.
--defaults-file must be given before other options.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/backends/mysql/test_creation.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/backends/mysql/test_creation.py b/tests/backends/mysql/test_creation.py index 2f6351d9bc..01e59d8758 100644 --- a/tests/backends/mysql/test_creation.py +++ b/tests/backends/mysql/test_creation.py @@ -1,3 +1,4 @@ +import subprocess import unittest from io import StringIO from unittest import mock @@ -50,3 +51,35 @@ class DatabaseCreationTests(SimpleTestCase): with mock.patch.object(DatabaseCreation, '_clone_db') as _clone_db: creation._clone_test_db('suffix', verbosity=0, keepdb=True) _clone_db.assert_not_called() + + def test_clone_test_db_options_ordering(self): + creation = DatabaseCreation(connection) + try: + saved_settings = connection.settings_dict + connection.settings_dict = { + 'NAME': 'source_db', + 'USER': '', + 'PASSWORD': '', + 'PORT': '', + 'HOST': '', + 'ENGINE': 'django.db.backends.mysql', + 'OPTIONS': { + 'read_default_file': 'my.cnf', + }, + } + with mock.patch.object(subprocess, 'Popen') as mocked_popen: + creation._clone_db('source_db', 'target_db') + mocked_popen.assert_has_calls([ + mock.call( + [ + 'mysqldump', + '--defaults-file=my.cnf', + '--routines', + '--events', + 'source_db', + ], + stdout=subprocess.PIPE, + ), + ]) + finally: + connection.settings_dict = saved_settings |
