Handle warning as error and exclude warning tests

This commit is contained in:
David Wobrock committed 2020-02-07 23:29:15 +01:00
1 parent d01875b3be
commit 71614bd377
6 files changed
+99 -51

No files matched your search

+4 -4
View File
@@ -53,7 +53,7 @@ class CacheTestCase(unittest.TestCase):
self.assertListEqual(
[
{
"err_msg": "NOT NULL constraint on columns",
"msg": "NOT NULL constraint on columns",
"code": "NOT_NULL",
"table": None,
"column": None,
@@ -105,7 +105,7 @@ class CacheTestCase(unittest.TestCase):
self.assertListEqual(
[
{
"err_msg": "NOT NULL constraint on columns",
"msg": "NOT NULL constraint on columns",
"code": "NOT_NULL",
"table": None,
"column": None,
@@ -132,7 +132,7 @@ class CacheTestCase(unittest.TestCase):
self.assertListEqual(
[
{
"err_msg": "NOT NULL constraint on columns",
"msg": "NOT NULL constraint on columns",
"code": "NOT_NULL",
"table": None,
"column": None,
@@ -245,7 +245,7 @@ class CacheTestCase(unittest.TestCase):
self.assertListEqual(
[
{
"err_msg": "NOT NULL constraint on columns",
"msg": "NOT NULL constraint on columns",
"code": "NOT_NULL",
"table": None,
"column": None,
+33 -3
View File
@@ -11,8 +11,7 @@ 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,
self.test_project_path, include_apps=fixtures.DATA_MIGRATIONS,
)
def test_reverse_data_migration(self):
@@ -26,7 +25,6 @@ class DataMigrationDetectionTestCase(unittest.TestCase):
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")
]
@@ -34,3 +32,35 @@ class DataMigrationDetectionTestCase(unittest.TestCase):
self.assertEqual(1, self.linter.nb_warnings)
self.assertFalse(self.linter.has_errors)
def test_exclude_warning_from_test(self):
self.linter = MigrationLinter(
self.test_project_path,
include_apps=fixtures.DATA_MIGRATIONS,
exclude_migration_tests=("REVERSIBLE_DATA_MIGRATION",),
)
reverse_migration = self.linter.migration_loader.disk_migrations[
("app_data_migrations", "0002_missing_reverse")
]
self.linter.lint_migration(reverse_migration)
self.assertEqual(0, self.linter.nb_warnings)
self.assertEqual(1, self.linter.nb_valid)
self.assertFalse(self.linter.has_errors)
def test_warning_as_error(self):
self.linter = MigrationLinter(
self.test_project_path,
include_apps=fixtures.DATA_MIGRATIONS,
warning_as_error=True,
)
reverse_migration = self.linter.migration_loader.disk_migrations[
("app_data_migrations", "0003_incorrect_arguments")
]
self.linter.lint_migration(reverse_migration)
self.assertEqual(0, self.linter.nb_warnings)
self.assertEqual(1, self.linter.nb_erroneous)
self.assertTrue(self.linter.has_errors)