diff --git a/health_check/management/commands/health_check.py b/health_check/management/commands/health_check.py index eb36ac88..191d50d1 100644 --- a/health_check/management/commands/health_check.py +++ b/health_check/management/commands/health_check.py @@ -10,7 +10,7 @@ class Command(CheckMixin, BaseCommand): help = "Run health checks and exit 0 if everything went well." def add_arguments(self, parser): - parser.add_argument("-s", '--subset', type=str, nargs=1) + parser.add_argument("-s", "--subset", type=str, nargs=1) def handle(self, *args, **options): # perform all checks diff --git a/health_check/mixins.py b/health_check/mixins.py index e32be97e..dd04180c 100644 --- a/health_check/mixins.py +++ b/health_check/mixins.py @@ -44,7 +44,7 @@ def filter_plugins(self, subset=None): if subset is None: return self.plugins - health_check_subsets = HEALTH_CHECK['SUBSETS'] + health_check_subsets = HEALTH_CHECK["SUBSETS"] if subset not in health_check_subsets or not self.plugins: raise Http404(f"Specify subset: '{subset}' does not exists.") diff --git a/tests/test_commands.py b/tests/test_commands.py index 7c7aaf15..da2a7aec 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -38,30 +38,25 @@ def test_command(self): ) def test_command_with_subset(self): - SUBSET_NAME_1 = 'subset-1' - SUBSET_NAME_2 = 'subset-2' - HEALTH_CHECK['SUBSETS'] = { + SUBSET_NAME_1 = "subset-1" + SUBSET_NAME_2 = "subset-2" + HEALTH_CHECK["SUBSETS"] = { SUBSET_NAME_1: ["OkPlugin"], - SUBSET_NAME_2: ["OkPlugin", "FailPlugin"] + SUBSET_NAME_2: ["OkPlugin", "FailPlugin"], } stdout = StringIO() - call_command(f"health_check", f"--subset={SUBSET_NAME_1}", stdout=stdout) + call_command("health_check", f"--subset={SUBSET_NAME_1}", stdout=stdout) stdout.seek(0) - assert stdout.read() == ( - "OkPlugin ... working\n" - ) - + assert stdout.read() == ("OkPlugin ... working\n") def test_command_with_failed_check_subset(self): - SUBSET_NAME = 'subset-2' - HEALTH_CHECK['SUBSETS'] = { - SUBSET_NAME: ["OkPlugin", "FailPlugin"] - } + SUBSET_NAME = "subset-2" + HEALTH_CHECK["SUBSETS"] = {SUBSET_NAME: ["OkPlugin", "FailPlugin"]} stdout = StringIO() with pytest.raises(SystemExit): - call_command(f"health_check", f"--subset={SUBSET_NAME}", stdout=stdout) + call_command("health_check", f"--subset={SUBSET_NAME}", stdout=stdout) stdout.seek(0) assert stdout.read() == ( "FailPlugin ... unknown error: Oops\n" @@ -69,15 +64,15 @@ def test_command_with_failed_check_subset(self): ) def test_command_with_non_existence_subset(self): - SUBSET_NAME = 'subset-2' + SUBSET_NAME = "subset-2" NON_EXISTENCE_SUBSET_NAME = "abcdef12" - HEALTH_CHECK['SUBSETS'] = { - SUBSET_NAME: ["OkPlugin"] - } + HEALTH_CHECK["SUBSETS"] = {SUBSET_NAME: ["OkPlugin"]} stdout = StringIO() with pytest.raises(SystemExit): - call_command(f"health_check", f"--subset={NON_EXISTENCE_SUBSET_NAME}", stdout=stdout) + call_command( + "health_check", f"--subset={NON_EXISTENCE_SUBSET_NAME}", stdout=stdout + ) stdout.seek(0) assert stdout.read() == ( f"Specify subset: '{NON_EXISTENCE_SUBSET_NAME}' does not exists.\n" diff --git a/tests/test_views.py b/tests/test_views.py index 61047a29..d9161081 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -2,7 +2,6 @@ import pytest -from health_check import conf from health_check.backends import BaseHealthCheckBackend from health_check.conf import HEALTH_CHECK from health_check.exceptions import ServiceWarning @@ -292,7 +291,7 @@ def run_check(self, subset=None): plugin_dir.register(SuccessOneBackend) plugin_dir.register(SuccessTwoBackend) - HEALTH_CHECK['SUBSETS'] = { + HEALTH_CHECK["SUBSETS"] = { "startup-probe": ["SuccessOneBackend", "SuccessTwoBackend"], "liveness-probe": ["SuccessTwoBackend"], }