summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-12-26 13:56:08 -0500
committerTim Graham <timograham@gmail.com>2015-01-18 15:58:06 -0500
commit7e8cf74dc74539f40f4cea53c1e8bba82791fcb6 (patch)
treeed5ab7926f7856804b062b89326e62b8ee15ff94 /tests
parent9704b0a82e1f1c6ed0118f948a56652594f0a43b (diff)
Removed support for syncing apps without migrations per deprecation timeline.
Kept support for creating models without migrations when running tests (especially for Django's test suite).
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_scripts/tests.py7
-rw-r--r--tests/bash_completion/tests.py2
-rw-r--r--tests/commands_sql/__init__.py0
-rw-r--r--tests/commands_sql/models.py11
-rw-r--r--tests/commands_sql/tests.py111
-rw-r--r--tests/commands_sql_migrations/__init__.py0
-rw-r--r--tests/commands_sql_migrations/migrations/0001_initial.py33
-rw-r--r--tests/commands_sql_migrations/migrations/__init__.py0
-rw-r--r--tests/commands_sql_migrations/models.py10
-rw-r--r--tests/commands_sql_migrations/tests.py39
-rw-r--r--tests/model_inheritance/tests.py2
-rw-r--r--tests/proxy_model_inheritance/tests.py2
12 files changed, 3 insertions, 214 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index cbe2a5e6e3..c7603e3914 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -319,13 +319,6 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
self.assertNoOutput(err)
self.assertOutput(out, SYSTEM_CHECK_MSG)
- def test_sqlclear_builtin_with_settings(self):
- "fulldefault: django-admin builtin commands succeed if a setting file is provided"
- args = ['sqlclear', '--settings=test_project.settings', 'complex_app']
- out, err = self.run_django_admin(args)
- self.assertNoOutput(err)
- self.assertOutput(out, '-- App creates no tables in the database. Nothing to do.')
-
def test_builtin_with_environment(self):
"fulldefault: django-admin builtin commands succeed if the environment contains settings"
args = ['check', 'admin_scripts']
diff --git a/tests/bash_completion/tests.py b/tests/bash_completion/tests.py
index 8b284389c0..b12a0cecdc 100644
--- a/tests/bash_completion/tests.py
+++ b/tests/bash_completion/tests.py
@@ -78,7 +78,7 @@ class BashCompletionTests(unittest.TestCase):
"Subcommands can be autocompleted"
self._user_input('django-admin sql')
output = self._run_autocomplete()
- self.assertEqual(output, ['sql sqlall sqlclear sqldropindexes sqlflush sqlindexes sqlmigrate sqlsequencereset'])
+ self.assertEqual(output, ['sqlflush sqlmigrate sqlsequencereset'])
def test_completed_subcommand(self):
"Show option flags in case a subcommand is completed"
diff --git a/tests/commands_sql/__init__.py b/tests/commands_sql/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/commands_sql/__init__.py
+++ /dev/null
diff --git a/tests/commands_sql/models.py b/tests/commands_sql/models.py
deleted file mode 100644
index fe5768b3dd..0000000000
--- a/tests/commands_sql/models.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from django.db import models
-
-
-class Comment(models.Model):
- pass
-
-
-class Book(models.Model):
- title = models.CharField(max_length=100, db_index=True)
- comments = models.ManyToManyField(Comment)
- counter = models.PositiveIntegerField()
diff --git a/tests/commands_sql/tests.py b/tests/commands_sql/tests.py
deleted file mode 100644
index 5eb9f0191a..0000000000
--- a/tests/commands_sql/tests.py
+++ /dev/null
@@ -1,111 +0,0 @@
-from __future__ import unicode_literals
-
-import re
-import unittest
-
-from django.apps import apps
-from django.core.management.color import no_style
-from django.core.management.sql import (sql_create, sql_delete, sql_indexes,
- sql_destroy_indexes, sql_all)
-from django.db import connections, DEFAULT_DB_ALIAS
-from django.test import TestCase, ignore_warnings, override_settings
-from django.utils import six
-from django.utils.deprecation import RemovedInDjango20Warning
-
-# See also initial_sql_regress for 'custom_sql_for_model' tests
-
-
-class SQLCommandsTestCase(TestCase):
- """Tests for several functions in django/core/management/sql.py"""
- def count_ddl(self, output, cmd):
- return len([o for o in output if o.startswith(cmd)])
-
- def test_sql_create(self):
- app_config = apps.get_app_config('commands_sql')
- output = sql_create(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
-
- tables = set()
- create_table_re = re.compile(r'^create table .(?P<table>[\w_]+).*', re.IGNORECASE)
- reference_re = re.compile(r'.* references .(?P<table>[\w_]+).*', re.IGNORECASE)
- for statement in output:
- create_table = create_table_re.match(statement)
- if create_table:
- # Lower since Oracle's table names are upper cased.
- tables.add(create_table.group('table').lower())
- continue
- reference = reference_re.match(statement)
- if reference:
- # Lower since Oracle's table names are upper cased.
- table = reference.group('table').lower()
- self.assertIn(
- table, tables, "The table %s is referenced before its creation." % table
- )
-
- self.assertEqual(tables, {
- 'commands_sql_comment', 'commands_sql_book', 'commands_sql_book_comments'
- })
-
- @unittest.skipUnless('PositiveIntegerField' in connections[DEFAULT_DB_ALIAS].data_type_check_constraints, 'Backend does not have checks.')
- def test_sql_create_check(self):
- """Regression test for #23416 -- Check that db_params['check'] is respected."""
- app_config = apps.get_app_config('commands_sql')
- output = sql_create(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
- success = False
- for statement in output:
- if 'CHECK' in statement:
- success = True
- if not success:
- self.fail("'CHECK' not found in output %s" % output)
-
- def test_sql_delete(self):
- app_config = apps.get_app_config('commands_sql')
- output = sql_delete(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False)
- drop_tables = [o for o in output if o.startswith('DROP TABLE')]
- self.assertEqual(len(drop_tables), 3)
- # Lower so that Oracle's upper case tbl names wont break
- sql = drop_tables[-1].lower()
- six.assertRegex(self, sql, r'^drop table .commands_sql_comment.*')
-
- @ignore_warnings(category=RemovedInDjango20Warning)
- def test_sql_indexes(self):
- app_config = apps.get_app_config('commands_sql')
- output = sql_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
- # Number of indexes is backend-dependent
- self.assertTrue(1 <= self.count_ddl(output, 'CREATE INDEX') <= 4)
-
- def test_sql_destroy_indexes(self):
- app_config = apps.get_app_config('commands_sql')
- output = sql_destroy_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
- # Number of indexes is backend-dependent
- self.assertTrue(1 <= self.count_ddl(output, 'DROP INDEX') <= 4)
-
- @ignore_warnings(category=RemovedInDjango20Warning)
- def test_sql_all(self):
- app_config = apps.get_app_config('commands_sql')
- output = sql_all(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
-
- self.assertEqual(self.count_ddl(output, 'CREATE TABLE'), 3)
- # Number of indexes is backend-dependent
- self.assertTrue(1 <= self.count_ddl(output, 'CREATE INDEX') <= 4)
-
-
-class TestRouter(object):
- def allow_migrate(self, db, model):
- return False
-
-
-@override_settings(DATABASE_ROUTERS=[TestRouter()])
-class SQLCommandsRouterTestCase(TestCase):
-
- def test_router_honored(self):
- app_config = apps.get_app_config('commands_sql')
- for sql_command in (sql_all, sql_create, sql_delete, sql_indexes, sql_destroy_indexes):
- if sql_command is sql_delete:
- output = sql_command(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False)
- # "App creates no tables in the database. Nothing to do."
- expected_output = 1
- else:
- output = sql_command(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
- expected_output = 0
- self.assertEqual(len(output), expected_output,
- "%s command is not honoring routers" % sql_command.__name__)
diff --git a/tests/commands_sql_migrations/__init__.py b/tests/commands_sql_migrations/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/commands_sql_migrations/__init__.py
+++ /dev/null
diff --git a/tests/commands_sql_migrations/migrations/0001_initial.py b/tests/commands_sql_migrations/migrations/0001_initial.py
deleted file mode 100644
index 39a53bf68f..0000000000
--- a/tests/commands_sql_migrations/migrations/0001_initial.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
-from django.db import models, migrations
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ]
-
- operations = [
- migrations.CreateModel(
- name='Comment',
- fields=[
- ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
- ],
- options={
- },
- bases=(models.Model,),
- ),
- migrations.CreateModel(
- name='Book',
- fields=[
- ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
- ('title', models.CharField(db_index=True, max_length=100)),
- ('comments', models.ManyToManyField(to='commands_sql_migrations.Comment')),
- ],
- options={
- },
- bases=(models.Model,),
- ),
- ]
diff --git a/tests/commands_sql_migrations/migrations/__init__.py b/tests/commands_sql_migrations/migrations/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/commands_sql_migrations/migrations/__init__.py
+++ /dev/null
diff --git a/tests/commands_sql_migrations/models.py b/tests/commands_sql_migrations/models.py
deleted file mode 100644
index 78ad722307..0000000000
--- a/tests/commands_sql_migrations/models.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from django.db import models
-
-
-class Comment(models.Model):
- pass
-
-
-class Book(models.Model):
- title = models.CharField(max_length=100, db_index=True)
- comments = models.ManyToManyField(Comment)
diff --git a/tests/commands_sql_migrations/tests.py b/tests/commands_sql_migrations/tests.py
deleted file mode 100644
index 23b37a0f8f..0000000000
--- a/tests/commands_sql_migrations/tests.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from __future__ import unicode_literals
-
-from django.apps import apps
-from django.core.management import CommandError
-from django.core.management.color import no_style
-from django.core.management.sql import (sql_create, sql_delete, sql_indexes,
- sql_destroy_indexes, sql_all)
-from django.db import connections, DEFAULT_DB_ALIAS
-from django.test import TestCase
-
-
-class SQLCommandsMigrationsTestCase(TestCase):
- """Tests that apps with migrations can not use sql commands."""
-
- def test_sql_create(self):
- app_config = apps.get_app_config('commands_sql_migrations')
- with self.assertRaises(CommandError):
- sql_create(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
-
- def test_sql_delete(self):
- app_config = apps.get_app_config('commands_sql_migrations')
- with self.assertRaises(CommandError):
- sql_delete(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False)
-
- def test_sql_indexes(self):
- app_config = apps.get_app_config('commands_sql_migrations')
- with self.assertRaises(CommandError):
- sql_indexes(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
-
- def test_sql_destroy_indexes(self):
- app_config = apps.get_app_config('commands_sql_migrations')
- with self.assertRaises(CommandError):
- sql_destroy_indexes(app_config, no_style(),
- connections[DEFAULT_DB_ALIAS])
-
- def test_sql_all(self):
- app_config = apps.get_app_config('commands_sql_migrations')
- with self.assertRaises(CommandError):
- sql_all(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py
index 10721a6b3f..e207fe9a84 100644
--- a/tests/model_inheritance/tests.py
+++ b/tests/model_inheritance/tests.py
@@ -404,7 +404,7 @@ class InheritanceSameModelNameTests(TransactionTestCase):
def test_inheritance_with_same_model_name(self):
with self.modify_settings(
INSTALLED_APPS={'append': ['model_inheritance.same_model_name']}):
- call_command('migrate', verbosity=0)
+ call_command('migrate', verbosity=0, run_syncdb=True)
from .same_model_name.models import Copy
copy = self.title.attached_same_model_name_copy_set.create(
content='The Web framework for perfectionists with deadlines.',
diff --git a/tests/proxy_model_inheritance/tests.py b/tests/proxy_model_inheritance/tests.py
index 78e3c2607e..3678466e8c 100644
--- a/tests/proxy_model_inheritance/tests.py
+++ b/tests/proxy_model_inheritance/tests.py
@@ -22,7 +22,7 @@ class ProxyModelInheritanceTests(TransactionTestCase):
def test_table_exists(self):
with extend_sys_path(os.path.dirname(os.path.abspath(upath(__file__)))):
with self.modify_settings(INSTALLED_APPS={'append': ['app1', 'app2']}):
- call_command('migrate', verbosity=0)
+ call_command('migrate', verbosity=0, run_syncdb=True)
from app1.models import ProxyModel
from app2.models import NiceModel
self.assertEqual(NiceModel.objects.all().count(), 0)