mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Fixed tests
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user