56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
|
|
# retoor <retoor@molodetz.nl>
|
||
|
|
|
||
|
|
import os
|
||
|
|
import subprocess
|
||
|
|
import sys
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from devplacepy_services.base.config import PROFILES
|
||
|
|
|
||
|
|
SERVICE_MODULES = (
|
||
|
|
"devplacepy_services.database.main",
|
||
|
|
"devplacepy_services.pubsub.main",
|
||
|
|
"devplacepy_services.web.main",
|
||
|
|
"devplacepy_services.gateway.main",
|
||
|
|
"devplacepy_services.jobs.main",
|
||
|
|
"devplacepy_services.devii.main",
|
||
|
|
"devplacepy_services.bot.main",
|
||
|
|
"devplacepy_services.backup.main",
|
||
|
|
"devplacepy_services.containers.main",
|
||
|
|
"devplacepy_services.telegram.main",
|
||
|
|
"devplacepy_services.email.main",
|
||
|
|
"devplacepy_services.news.main",
|
||
|
|
"devplacepy_services.gitea.main",
|
||
|
|
"devplacepy_services.audit.main",
|
||
|
|
"devplacepy_services.xmlrpc.main",
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("module_name", SERVICE_MODULES)
|
||
|
|
def test_service_imports(module_name):
|
||
|
|
env = os.environ.copy()
|
||
|
|
env["DEVPLACE_DISABLE_SERVICES"] = "1"
|
||
|
|
env["DEVPLACE_DATABASE_URL"] = "sqlite:///:memory:"
|
||
|
|
env.pop("DEVPLACE_REMOTE_DB", None)
|
||
|
|
env.pop("DEVPLACE_DB_SERVICE", None)
|
||
|
|
script = (
|
||
|
|
f"import importlib; m = importlib.import_module('{module_name}'); "
|
||
|
|
"assert hasattr(m, 'app')"
|
||
|
|
)
|
||
|
|
result = subprocess.run(
|
||
|
|
[sys.executable, "-c", script],
|
||
|
|
env=env,
|
||
|
|
capture_output=True,
|
||
|
|
text=True,
|
||
|
|
timeout=30,
|
||
|
|
check=False,
|
||
|
|
)
|
||
|
|
assert result.returncode == 0, result.stderr or result.stdout
|
||
|
|
|
||
|
|
|
||
|
|
def test_port_profiles_complete():
|
||
|
|
for profile in ("micro-dev", "micro-test", "micro-prod"):
|
||
|
|
ports = PROFILES[profile]
|
||
|
|
assert "web" in ports
|
||
|
|
assert ports["web"] in (10500, 20500)
|