test: Make sure blocking of some management commands actually works
This commit is contained in:
parent
6dd9abdb85
commit
49f4ab2d76
|
@ -1,5 +1,8 @@
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.core.management import call_command
|
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.federation import models as federation_models
|
||||||
from funkwhale_api.music import models as music_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.Artist.objects.count() == 5
|
||||||
assert music_models.Album.objects.count() == 10
|
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)
|
||||||
|
|
Loading…
Reference in New Issue