mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #3948 from modoboa/3517-fix-dbport
fix: rewrite port detection value
This commit is contained in:
@@ -95,16 +95,19 @@ query = {{ query|safe }}
|
||||
if dburl
|
||||
else settings.DATABASES["default"]
|
||||
)
|
||||
dbhost = db_settings.get("HOST", "127.0.0.1")
|
||||
if "sqlite" in db_settings["ENGINE"]:
|
||||
dbtype = "sqlite"
|
||||
dbport = None
|
||||
elif "postgresql" in db_settings["ENGINE"]:
|
||||
dbtype = "postgres"
|
||||
dbport = db_settings.get("PORT", "5432")
|
||||
else:
|
||||
dbtype = "mysql"
|
||||
dbhost = db_settings.get("HOST", "127.0.0.1")
|
||||
dbport = db_settings.get("PORT", "")
|
||||
if len(dbport):
|
||||
dbhost += ":" + dbport
|
||||
dbport = db_settings.get("PORT", "3306")
|
||||
|
||||
if dbport:
|
||||
dbhost += f":{dbport}"
|
||||
|
||||
commandline = "{} {}".format(
|
||||
os.path.basename(sys.argv[0]), " ".join(sys.argv[1:])
|
||||
|
||||
@@ -4,6 +4,7 @@ from io import StringIO
|
||||
import json
|
||||
import pathlib
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import httmock
|
||||
from dateutil.relativedelta import relativedelta
|
||||
@@ -133,6 +134,21 @@ class ManagementCommandsTestCase(SimpleModoTestCase):
|
||||
]:
|
||||
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):
|
||||
"""Run clean_inactive_accounts command."""
|
||||
management.call_command("load_initial_data")
|
||||
|
||||
Reference in New Issue
Block a user