diff --git a/tests/functional/test_migration_linter.py b/tests/functional/test_migration_linter.py index 42d3cc8..ae2ba24 100644 --- a/tests/functional/test_migration_linter.py +++ b/tests/functional/test_migration_linter.py @@ -18,20 +18,20 @@ from django_migration_linter import MigrationLinter from tests import fixtures -class BackwardcompatibilityDetectionTest(unittest.TestCase): +class BaseBackwardCompatibilityDetection(object): def tearDown(self, *args, **kwargs): fixtures.clear_all_git_projects() super( - BackwardcompatibilityDetectionTest, + BaseBackwardCompatibilityDetection, self).tearDown(*args, **kwargs) def _test_linter_finds_errors(self, path, commit_id=None): - linter = MigrationLinter(path) + linter = MigrationLinter(path, database=self.DATABASE, no_cache=True) linter.lint_all_migrations(git_commit_id=commit_id) self.assertTrue(linter.has_errors) def _test_linter_finds_no_errors(self, path, commit_id=None): - linter = MigrationLinter(path) + linter = MigrationLinter(path, database=self.DATABASE, no_cache=True) linter.lint_all_migrations(git_commit_id=commit_id) self.assertFalse(linter.has_errors) @@ -85,3 +85,26 @@ class BackwardcompatibilityDetectionTest(unittest.TestCase): # test_project_path = fixtures.MULTI_COMMIT_PROJECT # fixtures.prepare_git_project(test_project_path) # self._test_linter_finds_no_errors(test_project_path, commit_id='tag1') + + +class MySqlBackwardCompatibilityDetectionTest(unittest.TestCase, BaseBackwardCompatibilityDetection): + DATABASE = "mysql" + +class SqliteBackwardCompatibilityDetectionTest(unittest.TestCase, BaseBackwardCompatibilityDetection): + DATABASE = "sqlite" + + def test_accept_not_null_column_followed_by_adding_default(self): + test_project_path = \ + fixtures.ADD_NOT_NULL_COLUMN_FOLLOWED_BY_DEFAULT_PROJECT + self._test_linter_finds_errors(test_project_path) + + def test_specify_git_hash_by_commit_hash(self): + test_project_path = fixtures.MULTI_COMMIT_PROJECT + fixtures.prepare_git_project(test_project_path) + self._test_linter_finds_errors( + test_project_path, + commit_id='d7125d5f4f0cc9623f670a66c54f131acc50032d') + + +class PostgresqlBackwardCompatibilityDetectionTest(unittest.TestCase, BaseBackwardCompatibilityDetection): + DATABASE = "postgresql" diff --git a/tests/test_project_fixtures/test_correct_project/test_project/settings.py b/tests/test_project_fixtures/test_correct_project/test_project/settings.py index 8145e44..8944ada 100644 --- a/tests/test_project_fixtures/test_correct_project/test_project/settings.py +++ b/tests/test_project_fixtures/test_correct_project/test_project/settings.py @@ -81,7 +81,16 @@ WSGI_APPLICATION = 'test_project.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django_fake_database_backends.backends.mysql' - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_deleted_migration_project/test_deleted_migration_project/settings.py b/tests/test_project_fixtures/test_deleted_migration_project/test_deleted_migration_project/settings.py index 94bfbb7..449a75d 100644 --- a/tests/test_project_fixtures/test_deleted_migration_project/test_deleted_migration_project/settings.py +++ b/tests/test_project_fixtures/test_deleted_migration_project/test_deleted_migration_project/settings.py @@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_deleted_migration_project.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django_fake_database_backends.backends.mysql', - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_django_without_git_project/test_django_without_git_project/settings.py b/tests/test_project_fixtures/test_django_without_git_project/test_django_without_git_project/settings.py index b91306d..652ca27 100644 --- a/tests/test_project_fixtures/test_django_without_git_project/test_django_without_git_project/settings.py +++ b/tests/test_project_fixtures/test_django_without_git_project/test_django_without_git_project/settings.py @@ -78,7 +78,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_non_root_git_project/django_project/test_project/settings.py b/tests/test_project_fixtures/test_non_root_git_project/django_project/test_project/settings.py index 986913f..e45afff 100644 --- a/tests/test_project_fixtures/test_non_root_git_project/django_project/test_project/settings.py +++ b/tests/test_project_fixtures/test_non_root_git_project/django_project/test_project/settings.py @@ -79,7 +79,16 @@ WSGI_APPLICATION = 'test_project.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django_fake_database_backends.backends.mysql' - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_add_not_null_column/test_project_add_not_null_column/settings.py b/tests/test_project_fixtures/test_project_add_not_null_column/test_project_add_not_null_column/settings.py index 95a7313..c34167f 100644 --- a/tests/test_project_fixtures/test_project_add_not_null_column/test_project_add_not_null_column/settings.py +++ b/tests/test_project_fixtures/test_project_add_not_null_column/test_project_add_not_null_column/settings.py @@ -78,7 +78,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_add_not_null_column_followed_by_default/test_project_add_not_null_column_followed_by_default/settings.py b/tests/test_project_fixtures/test_project_add_not_null_column_followed_by_default/test_project_add_not_null_column_followed_by_default/settings.py index 6070f2b..f0c3aa1 100644 --- a/tests/test_project_fixtures/test_project_add_not_null_column_followed_by_default/test_project_add_not_null_column_followed_by_default/settings.py +++ b/tests/test_project_fixtures/test_project_add_not_null_column_followed_by_default/test_project_add_not_null_column_followed_by_default/settings.py @@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_project_add_not_null_column_followed_by_default.wsgi.ap DATABASES = { 'default': { 'ENGINE': 'django_fake_database_backends.backends.mysql', - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_alter_column/test_project_alter_column/settings.py b/tests/test_project_fixtures/test_project_alter_column/test_project_alter_column/settings.py index 7d04288..93a6b70 100644 --- a/tests/test_project_fixtures/test_project_alter_column/test_project_alter_column/settings.py +++ b/tests/test_project_fixtures/test_project_alter_column/test_project_alter_column/settings.py @@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_project_alter_column.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django_fake_database_backends.backends.mysql' - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_create_table_with_not_null_column/test_project_create_table_with_not_null_column/settings.py b/tests/test_project_fixtures/test_project_create_table_with_not_null_column/test_project_create_table_with_not_null_column/settings.py index 7ccafd5..d1cd093 100644 --- a/tests/test_project_fixtures/test_project_create_table_with_not_null_column/test_project_create_table_with_not_null_column/settings.py +++ b/tests/test_project_fixtures/test_project_create_table_with_not_null_column/test_project_create_table_with_not_null_column/settings.py @@ -78,7 +78,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_drop_column/test_project_drop_column/settings.py b/tests/test_project_fixtures/test_project_drop_column/test_project_drop_column/settings.py index 62ba4ba..cdd3b93 100644 --- a/tests/test_project_fixtures/test_project_drop_column/test_project_drop_column/settings.py +++ b/tests/test_project_fixtures/test_project_drop_column/test_project_drop_column/settings.py @@ -78,7 +78,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_ignore_migration/test_project_ignore_migration/settings.py b/tests/test_project_fixtures/test_project_ignore_migration/test_project_ignore_migration/settings.py index 39bfb6c..af1db8f 100644 --- a/tests/test_project_fixtures/test_project_ignore_migration/test_project_ignore_migration/settings.py +++ b/tests/test_project_fixtures/test_project_ignore_migration/test_project_ignore_migration/settings.py @@ -78,7 +78,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_multi_commit/test_project_multi_commit/settings.py b/tests/test_project_fixtures/test_project_multi_commit/test_project_multi_commit/settings.py index 80c1a28..c5439eb 100644 --- a/tests/test_project_fixtures/test_project_multi_commit/test_project_multi_commit/settings.py +++ b/tests/test_project_fixtures/test_project_multi_commit/test_project_multi_commit/settings.py @@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_project_multi_commit.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django_fake_database_backends.backends.mysql', - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_rename_column/test_project_rename_column/settings.py b/tests/test_project_fixtures/test_project_rename_column/test_project_rename_column/settings.py index 62bc1d2..126901b 100644 --- a/tests/test_project_fixtures/test_project_rename_column/test_project_rename_column/settings.py +++ b/tests/test_project_fixtures/test_project_rename_column/test_project_rename_column/settings.py @@ -78,7 +78,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, } diff --git a/tests/test_project_fixtures/test_project_rename_table/test_project_rename_table/settings.py b/tests/test_project_fixtures/test_project_rename_table/test_project_rename_table/settings.py index 92a21e6..79a5ee2 100644 --- a/tests/test_project_fixtures/test_project_rename_table/test_project_rename_table/settings.py +++ b/tests/test_project_fixtures/test_project_rename_table/test_project_rename_table/settings.py @@ -78,7 +78,16 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } + }, + 'mysql': { + 'ENGINE': 'django_fake_database_backends.backends.mysql', + }, + 'sqlite': { + 'ENGINE': 'django_fake_database_backends.backends.sqlite3', + }, + 'postgresql': { + 'ENGINE': 'django_fake_database_backends.backends.postgresql', + }, }