diff options
| author | Moayad Mardini <moayad.m@gmail.com> | 2014-06-10 22:35:48 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-06-11 11:40:08 -0400 |
| commit | 7bd2ad1dd9fc449ed1b4832fab5c975d7c8aa895 (patch) | |
| tree | adeecba68247fcb6ca7525af3f05442397eb467d | |
| parent | 1ff11304dcebbabdede8ef3d659ca0e54055e2fd (diff) | |
[1.7.x] Created a new tests folder (`model_options`).
And moved `tablespaces` option tests to it.
The new folder can be used to test models/options, like the new option
added in refs #22778.
Backport of 5a3ae7e260 from master
| -rw-r--r-- | tests/model_options/__init__.py (renamed from tests/tablespaces/__init__.py) | 0 | ||||
| -rw-r--r-- | tests/model_options/models/__init__.py | 0 | ||||
| -rw-r--r-- | tests/model_options/models/tablespaces.py (renamed from tests/tablespaces/models.py) | 8 | ||||
| -rw-r--r-- | tests/model_options/test_tablespaces.py (renamed from tests/tablespaces/tests.py) | 22 |
4 files changed, 16 insertions, 14 deletions
diff --git a/tests/tablespaces/__init__.py b/tests/model_options/__init__.py index e69de29bb2..e69de29bb2 100644 --- a/tests/tablespaces/__init__.py +++ b/tests/model_options/__init__.py diff --git a/tests/model_options/models/__init__.py b/tests/model_options/models/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/model_options/models/__init__.py diff --git a/tests/tablespaces/models.py b/tests/model_options/models/tablespaces.py index ecd1944294..56e22e973a 100644 --- a/tests/tablespaces/models.py +++ b/tests/model_options/models/tablespaces.py @@ -23,7 +23,7 @@ class Scientist(models.Model): name = models.CharField(max_length=50) class Meta: - db_table = 'tablespaces_scientistref' + db_table = 'model_options_scientistref' db_tablespace = 'tbl_tbsp' managed = False @@ -35,14 +35,14 @@ class Article(models.Model): reviewers = models.ManyToManyField(Scientist, related_name='articles_reviewed_set', db_tablespace='idx_tbsp') class Meta: - db_table = 'tablespaces_articleref' + db_table = 'model_options_articleref' db_tablespace = 'tbl_tbsp' managed = False # Also set the tables for automatically created models Authors = Article._meta.get_field('authors').rel.through -Authors._meta.db_table = 'tablespaces_articleref_authors' +Authors._meta.db_table = 'model_options_articleref_authors' Reviewers = Article._meta.get_field('reviewers').rel.through -Reviewers._meta.db_table = 'tablespaces_articleref_reviewers' +Reviewers._meta.db_table = 'model_options_articleref_reviewers' diff --git a/tests/tablespaces/tests.py b/tests/model_options/test_tablespaces.py index 8c69e70a19..ac331bd36c 100644 --- a/tests/tablespaces/tests.py +++ b/tests/model_options/test_tablespaces.py @@ -6,27 +6,29 @@ from django.db import connection from django.core.management.color import no_style from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature -from .models import Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef - -# We can't test the DEFAULT_TABLESPACE and DEFAULT_INDEX_TABLESPACE settings -# because they're evaluated when the model class is defined. As a consequence, -# @override_settings doesn't work, and the tests depend +from .models.tablespaces import (Article, ArticleRef, Authors, Reviewers, + Scientist, ScientistRef) def sql_for_table(model): - return '\n'.join(connection.creation.sql_create_model(model, no_style())[0]) + return '\n'.join(connection.creation.sql_create_model(model, + no_style())[0]) def sql_for_index(model): - return '\n'.join(connection.creation.sql_indexes_for_model(model, no_style())) + return '\n'.join(connection.creation.sql_indexes_for_model(model, + no_style())) +# We can't test the DEFAULT_TABLESPACE and DEFAULT_INDEX_TABLESPACE settings +# because they're evaluated when the model class is defined. As a consequence, +# @override_settings doesn't work, and the tests depend class TablespacesTests(TestCase): def setUp(self): # The unmanaged models need to be removed after the test in order to # prevent bad interactions with the flush operation in other tests. - self._old_models = apps.app_configs['tablespaces'].models.copy() + self._old_models = apps.app_configs['model_options'].models.copy() for model in Article, Authors, Reviewers, Scientist: model._meta.managed = True @@ -35,8 +37,8 @@ class TablespacesTests(TestCase): for model in Article, Authors, Reviewers, Scientist: model._meta.managed = False - apps.app_configs['tablespaces'].models = self._old_models - apps.all_models['tablespaces'] = self._old_models + apps.app_configs['model_options'].models = self._old_models + apps.all_models['model_options'] = self._old_models apps.clear_cache() def assertNumContains(self, haystack, needle, count): |
