Fixed tests

This commit is contained in:
Antoine Nguyen
2025-06-08 15:12:49 +02:00
parent 00806cbff8
commit 994a2dd93b
4 changed files with 11 additions and 13 deletions
+1 -5
View File
@@ -189,11 +189,7 @@ class ParametersMixin:
class SimpleModoTestCase(ParametersMixin, TestCase):
"""Simple class to add parameters editing."""
@classmethod
def setUpTestData(cls): # noqa
"""Create a default user."""
super().setUpTestData()
management.call_command("load_initial_data", "--no-frontend")
pass
class ModoTestCase(ParametersMixin, TestCase):
+1
View File
@@ -53,6 +53,7 @@ class ManagementCommandsTestCase(RunCommandsMixin, SimpleModoTestCase):
@classmethod
def setUpTestData(cls): # noqa
super().setUpTestData()
call_command("load_initial_data", "--no-frontend")
admin_factories.populate_database()
def test_logparser(self):
+1 -1
View File
@@ -165,7 +165,7 @@ class PDFCredentialViewTestCase(ModoAPITestCase):
def test_storage_dir_creation(self):
"""Test storage directory creation."""
self.set_global_parameter("storage_dir", "/nonexistentdir")
self.set_global_parameter("storage_dir", "/nonexistentdir2")
self._create_account("leon@test.com", expected_status=500)
def test_directory_check_settings(self):
+8 -7
View File
@@ -21,17 +21,18 @@ from modoboa.parameters import tools as param_tools
def init_storage_dir():
"""Create the directory where documents will be stored."""
storage_dir = param_tools.get_global_parameter("storage_dir")
if os.path.exists(storage_dir) and os.access(storage_dir, os.W_OK):
return
elif not os.access(storage_dir, os.W_OK) and os.path.exists(storage_dir):
raise InternalError(
_("Can't write to selected directory to store PDF " "documents")
)
if os.path.exists(storage_dir):
if os.access(storage_dir, os.W_OK):
return
else:
raise InternalError(
_("Can't write to selected directory to store PDF documents")
)
try:
os.mkdir(storage_dir)
except OSError as inst:
raise InternalError(
_("Failed to create the directory that will contain " "PDF documents (%s)")
_("Failed to create the directory that will contain PDF documents (%s)")
% inst
) from None