Update linter tests for multiple backends
Create a base test class and have 3 different backends for now: * mysql * sqlite3 * postgresql
This commit is contained in:
1 parent
ba83526339
commit
5c7dab8db2
14 files changed
+157
-17
No files matched your search
@@ -18,20 +18,20 @@ from django_migration_linter import MigrationLinter
|
|||||||
from tests import fixtures
|
from tests import fixtures
|
||||||
|
|
||||||
|
|
||||||
class BackwardcompatibilityDetectionTest(unittest.TestCase):
|
class BaseBackwardCompatibilityDetection(object):
|
||||||
def tearDown(self, *args, **kwargs):
|
def tearDown(self, *args, **kwargs):
|
||||||
fixtures.clear_all_git_projects()
|
fixtures.clear_all_git_projects()
|
||||||
super(
|
super(
|
||||||
BackwardcompatibilityDetectionTest,
|
BaseBackwardCompatibilityDetection,
|
||||||
self).tearDown(*args, **kwargs)
|
self).tearDown(*args, **kwargs)
|
||||||
|
|
||||||
def _test_linter_finds_errors(self, path, commit_id=None):
|
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)
|
linter.lint_all_migrations(git_commit_id=commit_id)
|
||||||
self.assertTrue(linter.has_errors)
|
self.assertTrue(linter.has_errors)
|
||||||
|
|
||||||
def _test_linter_finds_no_errors(self, path, commit_id=None):
|
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)
|
linter.lint_all_migrations(git_commit_id=commit_id)
|
||||||
self.assertFalse(linter.has_errors)
|
self.assertFalse(linter.has_errors)
|
||||||
|
|
||||||
@@ -85,3 +85,26 @@ class BackwardcompatibilityDetectionTest(unittest.TestCase):
|
|||||||
# test_project_path = fixtures.MULTI_COMMIT_PROJECT
|
# test_project_path = fixtures.MULTI_COMMIT_PROJECT
|
||||||
# fixtures.prepare_git_project(test_project_path)
|
# fixtures.prepare_git_project(test_project_path)
|
||||||
# self._test_linter_finds_no_errors(test_project_path, commit_id='tag1')
|
# 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"
|
||||||
@@ -81,7 +81,16 @@ WSGI_APPLICATION = 'test_project.wsgi.application'
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django_fake_database_backends.backends.mysql'
|
'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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_deleted_migration_project.wsgi.application'
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django_fake_database_backends.backends.mysql',
|
'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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -78,7 +78,16 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -79,7 +79,16 @@ WSGI_APPLICATION = 'test_project.wsgi.application'
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django_fake_database_backends.backends.mysql'
|
'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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -78,7 +78,16 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_project_add_not_null_column_followed_by_default.wsgi.ap
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django_fake_database_backends.backends.mysql',
|
'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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_project_alter_column.wsgi.application'
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django_fake_database_backends.backends.mysql'
|
'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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -78,7 +78,16 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -78,7 +78,16 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -78,7 +78,16 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -77,7 +77,16 @@ WSGI_APPLICATION = 'test_project_multi_commit.wsgi.application'
|
|||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django_fake_database_backends.backends.mysql',
|
'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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -78,7 +78,16 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -78,7 +78,16 @@ DATABASES = {
|
|||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': os.path.join(BASE_DIR, 'db.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',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user