diff --git a/tests/functional/test_lintmigrations_command.py b/tests/functional/test_lintmigrations_command.py new file mode 100644 index 0000000..b4dc1e8 --- /dev/null +++ b/tests/functional/test_lintmigrations_command.py @@ -0,0 +1,31 @@ +from unittest.mock import patch + +from django.core.management import call_command +from django.test import TransactionTestCase + + +class LintMigrationsCommandTestCase(TransactionTestCase): + databases = {"default", "sqlite"} + + def test_plain(self): + with self.assertRaises(SystemExit): + call_command("lintmigrations") + + def test_config_file_app_label(self): + with patch( + "django_migration_linter.management.commands.lintmigrations.Command.read_config_file" + ) as config_fn: + config_fn.return_value = {"app_label": "app_correct"} + call_command("lintmigrations") + + def test_command_line_app_label(self): + call_command("lintmigrations", app_label="app_correct") + + def test_command_line_and_config_file_app_label(self): + with patch( + "django_migration_linter.management.commands.lintmigrations.Command.read_config_file" + ) as config_fn: + config_fn.return_value = {"app_label": "app_correct"} + + with self.assertRaises(SystemExit): + call_command("lintmigrations", app_label="app_drop_table")