diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2016-09-10 16:38:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-10 16:38:05 -0700 |
| commit | 1ec1633cb294d8ce2a65ece6b56c258483596fba (patch) | |
| tree | 49e7163dad4220da3d99be0a5d981a1a735570a3 /tests | |
| parent | 0368d63a78b07e794138a65216b91eadbb47fc2f (diff) | |
Fixed #26401 -- Added BaseAuthConfig to use auth without migrations.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/auth_tests/test_apps.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/auth_tests/test_apps.py b/tests/auth_tests/test_apps.py new file mode 100644 index 0000000000..e1c386c95e --- /dev/null +++ b/tests/auth_tests/test_apps.py @@ -0,0 +1,61 @@ +import os +import shutil +import subprocess +import sys +import tempfile +import unittest + +from django.db import ConnectionHandler + +SETTINGS = """ +SECRET_KEY = 'django_auth_tests_secret_key' + +INSTALLED_APPS = [ + 'django.contrib.auth.apps.BaseAuthConfig', + 'django.contrib.contenttypes', +] + +MIGRATION_MODULES = {'auth': None} + +DATABASES = %(databases)r +""" + + +class AppConfigTests(unittest.TestCase): + def test_no_migrations(self): + project_path = tempfile.mkdtemp() + try: + databases = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(project_path, 'db.sqlite3'), + } + } + + with open(os.path.join(project_path, 'no_migrations.py'), 'w') as fp: + fp.write(SETTINGS % {'databases': databases}) + + with open(os.devnull, 'wb') as devnull: + cmd = [ + sys.executable, + '-m', 'django', + 'migrate', + '--settings', 'no_migrations', + '--pythonpath', project_path, + ] + returncode = subprocess.call(cmd, stdout=devnull, stderr=devnull) + + # Migrate command ran without errors. + self.assertEqual(returncode, 0) + + # Auth tables weren't created. + conns = ConnectionHandler(databases) + try: + self.assertEqual( + set(conns['default'].introspection.table_names()), + {'django_content_type', 'django_migrations'}, + ) + finally: + conns.close_all() + finally: + shutil.rmtree(project_path) |
