mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
fix: rewrite port detection value
This commit is contained in:
@@ -95,16 +95,19 @@ query = {{ query|safe }}
|
|||||||
if dburl
|
if dburl
|
||||||
else settings.DATABASES["default"]
|
else settings.DATABASES["default"]
|
||||||
)
|
)
|
||||||
|
dbhost = db_settings.get("HOST", "127.0.0.1")
|
||||||
if "sqlite" in db_settings["ENGINE"]:
|
if "sqlite" in db_settings["ENGINE"]:
|
||||||
dbtype = "sqlite"
|
dbtype = "sqlite"
|
||||||
|
dbport = None
|
||||||
elif "postgresql" in db_settings["ENGINE"]:
|
elif "postgresql" in db_settings["ENGINE"]:
|
||||||
dbtype = "postgres"
|
dbtype = "postgres"
|
||||||
|
dbport = db_settings.get("PORT", "5432")
|
||||||
else:
|
else:
|
||||||
dbtype = "mysql"
|
dbtype = "mysql"
|
||||||
dbhost = db_settings.get("HOST", "127.0.0.1")
|
dbport = db_settings.get("PORT", "3306")
|
||||||
dbport = db_settings.get("PORT", "")
|
|
||||||
if len(dbport):
|
if dbport:
|
||||||
dbhost += ":" + dbport
|
dbhost += f":{dbport}"
|
||||||
|
|
||||||
commandline = "{} {}".format(
|
commandline = "{} {}".format(
|
||||||
os.path.basename(sys.argv[0]), " ".join(sys.argv[1:])
|
os.path.basename(sys.argv[0]), " ".join(sys.argv[1:])
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from io import StringIO
|
|||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import httmock
|
import httmock
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
@@ -133,6 +134,21 @@ class ManagementCommandsTestCase(SimpleModoTestCase):
|
|||||||
]:
|
]:
|
||||||
self.assertFalse(config[param].startswith("http"))
|
self.assertFalse(config[param].startswith("http"))
|
||||||
|
|
||||||
|
def test_generate_postfix_maps(self):
|
||||||
|
"""Run generate_postfix_maps command"""
|
||||||
|
|
||||||
|
workdir = tempfile.mkdtemp()
|
||||||
|
# test SQLite URL
|
||||||
|
management.call_command("generate_postfix_maps", "--dburl", "sqlite://testdb.sqlite", "--destdir", workdir)
|
||||||
|
|
||||||
|
workdir = tempfile.mkdtemp()
|
||||||
|
# test PostgreSQL URL
|
||||||
|
management.call_command("generate_postfix_maps", "--dburl", "postgres://user:password@localhost/testdb", "--destdir", workdir)
|
||||||
|
|
||||||
|
workdir = tempfile.mkdtemp()
|
||||||
|
# test MySQL URL
|
||||||
|
management.call_command("generate_postfix_maps", "--dburl", "mysql://user:password@localhost/testdb", "--destdir", workdir)
|
||||||
|
|
||||||
def test_clean_inactive_accounts(self):
|
def test_clean_inactive_accounts(self):
|
||||||
"""Run clean_inactive_accounts command."""
|
"""Run clean_inactive_accounts command."""
|
||||||
management.call_command("load_initial_data")
|
management.call_command("load_initial_data")
|
||||||
|
|||||||
Reference in New Issue
Block a user