Do not deploy frontend during tests

This commit is contained in:
Antoine Nguyen
2024-07-10 15:30:25 +02:00
parent 05d521704d
commit 7a0af5568c
2 changed files with 15 additions and 6 deletions
@@ -51,6 +51,12 @@ class Command(BaseCommand):
default=False,
help="Setup dev environment. DO NOT USE IN PRODUCTION",
)
parser.add_argument(
"--no-frontend",
action="store_true",
default=False,
help="Omit everything related to frontend initialisation",
)
def handle(self, *args, **options):
"""Command entry point."""
@@ -90,6 +96,14 @@ class Command(BaseCommand):
else:
signals.initial_data_loaded.send(sender=self.__class__, extname=extname)
if options["extra_fixtures"]:
from modoboa.admin import factories
factories.populate_database()
if options["no_frontend"]:
return
app_model = get_application_model()
allowed_host = getattr(settings, "ALLOWED_HOSTS", None)
if allowed_host is not None:
@@ -136,8 +150,3 @@ class Command(BaseCommand):
}}
"""
)
if options["extra_fixtures"]:
from modoboa.admin import factories
factories.populate_database()
+1 -1
View File
@@ -65,7 +65,7 @@ class ModoTestCase(ParametersMixin, TestCase):
def setUpTestData(cls): # noqa
"""Create a default user."""
super(ModoTestCase, cls).setUpTestData()
management.call_command("load_initial_data")
management.call_command("load_initial_data", "--no-frontend")
def setUp(self, username="admin", password="password"):
"""Initiate test context."""