Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add funtional tests for lintmigrations command
- Loading branch information
1 parent
059c57a
commit 8a740a5
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |