add warnings and RunPython basic linting

This commit is contained in:
David Wobrock committed 2020-02-07 23:29:15 +01:00
1 parent 691b1b82cb
commit d01875b3be
5 files changed
+134 -8

No files matched your search

+1
View File
@@ -10,3 +10,4 @@ ALTER_COLUMN = "app_alter_column"
ALTER_COLUMN_DROP_NOT_NULL = "app_alter_column_drop_not_null"
DROP_UNIQUE_TOGETHER = "app_unique_together"
ADD_MANYTOMANY_FIELD = "app_add_manytomany_field"
DATA_MIGRATIONS = "app_data_migrations"
+36
View File
@@ -0,0 +1,36 @@
import os
import unittest
from django.conf import settings
from django_migration_linter import MigrationLinter
from tests import fixtures
class DataMigrationDetectionTestCase(unittest.TestCase):
def setUp(self, *args, **kwargs):
self.test_project_path = os.path.dirname(settings.BASE_DIR)
self.linter = MigrationLinter(
self.test_project_path,
include_apps=fixtures.DATA_MIGRATIONS,
)
def test_reverse_data_migration(self):
self.assertEqual(0, self.linter.nb_warnings)
reverse_migration = self.linter.migration_loader.disk_migrations[
("app_data_migrations", "0002_missing_reverse")
]
self.linter.lint_migration(reverse_migration)
self.assertEqual(1, self.linter.nb_warnings)
self.assertFalse(self.linter.has_errors)
def test_reverse_data_migration_ignore(self):
self.assertEqual(0, self.linter.nb_warnings)
reverse_migration = self.linter.migration_loader.disk_migrations[
("app_data_migrations", "0003_incorrect_arguments")
]
self.linter.lint_migration(reverse_migration)
self.assertEqual(1, self.linter.nb_warnings)
self.assertFalse(self.linter.has_errors)
+1
View File
@@ -53,6 +53,7 @@ INSTALLED_APPS = [
"tests.test_project.app_rename_column",
"tests.test_project.app_rename_table",
"tests.test_project.app_unique_together",
"tests.test_project.app_data_migrations",
]
MIDDLEWARE = [