diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2014-02-09 10:46:57 +0000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2014-02-09 10:46:57 +0000 |
| commit | 38b4adc6960d28483124509aa363dadbe8cc17a6 (patch) | |
| tree | 364b0c3fad4001c73ee5a21500bc8721c508e0fa /tests | |
| parent | 46a87214caf07f8b21adce5d1733d5d598d16e26 (diff) | |
| parent | a3e0d7753d8a3cec7efcc69b9af8160bdf17947b (diff) | |
Merge pull request #2244 from mlavin/21856-migration-checks
Fixed #21856: Allow Empty DATABASES Setting
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_checks.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/migrations/test_checks.py b/tests/migrations/test_checks.py new file mode 100644 index 0000000000..9ba5bb8e25 --- /dev/null +++ b/tests/migrations/test_checks.py @@ -0,0 +1,43 @@ +# encoding: utf8 +from django.core import checks +from django.core.checks.migrations import check_migrations +from django.test import TestCase, override_settings + +from .test_base import MigrationTestBase + + +class CheckMigrationTests(MigrationTestBase): + """ + Test checks for unapplied migrations. + """ + + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) + def test_unapplied(self): + """ + check_migrations should return a warning when there are unapplied migrations. + """ + expected = [ + checks.Warning( + "You have unapplied migrations; " + "your app may not work properly until they are applied.", + hint="Run 'python manage.py migrate' to apply them.", + ) + ] + errors = check_migrations() + self.assertEqual(errors, expected) + + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}, DATABASES={}) + def test_no_databases(self): + """ + Migration checks should not consider unapplied migrations if there is + no database configured. + """ + errors = check_migrations() + self.assertEqual(errors, []) + + def test_no_unapplied(self): + """ + No warning should be issued if all migrations have been applied. + """ + errors = check_migrations() + self.assertEqual(errors, []) |
