Skip to content

Commit

Permalink
Add funtional tests for lintmigrations command
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Wobrock committed Jan 28, 2022
1 parent 059c57a commit 8a740a5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions 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")

0 comments on commit 8a740a5

Please sign in to comment.