From 49f4ab2d76cef7f6253fe9fbe3b59cfd8ffba082 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Sat, 10 Jun 2023 20:24:18 +0200 Subject: [PATCH] test: Make sure blocking of some management commands actually works --- api/tests/common/test_commands.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/api/tests/common/test_commands.py b/api/tests/common/test_commands.py index eb0d77f9e..304ee799b 100644 --- a/api/tests/common/test_commands.py +++ b/api/tests/common/test_commands.py @@ -1,5 +1,8 @@ +import os + import pytest from django.core.management import call_command +from django.core.management.base import CommandError from funkwhale_api.federation import models as federation_models from funkwhale_api.music import models as music_models @@ -97,3 +100,19 @@ def test_load_test_data_skip_dependencies(factories): assert music_models.Artist.objects.count() == 5 assert music_models.Album.objects.count() == 10 + + +commands = ["createsuperuser", "makemigrations"] + + +@pytest.mark.parametrize("command", commands) +def test_blocked_commands(command): + with pytest.raises(CommandError): + call_command(command) + + +@pytest.mark.parametrize("command", commands) +def test_unblocked_commands(command, mocker): + mocker.patch.dict(os.environ, {"FORCE": "1"}) + + call_command(command)