Compare commits

...

2 Commits

Author SHA1 Message Date
holger krekel
04e3a4eef7 move tests into cmdeploy 2023-12-11 17:59:01 +01:00
holger krekel
cf6ed68a12 rename deploy_chatmail to cmdeploy 2023-12-11 17:59:01 +01:00
41 changed files with 20 additions and 22 deletions

View File

@@ -31,7 +31,7 @@ jobs:
run: cmdeploy fmt -v run: cmdeploy fmt -v
- name: run deploy-chatmail offline tests - name: run deploy-chatmail offline tests
run: pytest tests run: pytest --pyargs cmdeploy
- name: initialize with chatmail domain - name: initialize with chatmail domain
run: cmdeploy init chat.example.org run: cmdeploy init chat.example.org

View File

@@ -3,8 +3,8 @@ requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]
name = "deploy-chatmail" name = "cmdeploy"
version = "0.1" version = "0.2"
dependencies = [ dependencies = [
"pyinfra", "pyinfra",
"pillow", "pillow",
@@ -22,10 +22,11 @@ dependencies = [
] ]
[project.scripts] [project.scripts]
cmdeploy = "deploy_chatmail.cmdeploy:main" cmdeploy = "cmdeploy.cmdeploy:main"
[project.entry-points.pytest11] [project.entry-points.pytest11]
"chatmaild.testplugin" = "chatmaild.tests.plugin" "chatmaild.testplugin" = "chatmaild.tests.plugin"
"cmdeploy.testplugin" = "cmdeploy.tests.plugin"
[tool.pytest.ini_options] [tool.pytest.ini_options]
addopts = "-v -ra --strict-markers" addopts = "-v -ra --strict-markers"

View File

@@ -53,9 +53,9 @@ def run_cmd(args, out):
env = os.environ.copy() env = os.environ.copy()
env["CHATMAIL_DOMAIN"] = args.config.mail_domain env["CHATMAIL_DOMAIN"] = args.config.mail_domain
deploypy = "deploy-chatmail/src/deploy_chatmail/deploy.py" deploy_path = "cmdeploy/src/cmdeploy/deploy.py"
pyinf = "pyinfra --dry" if args.dry_run else "pyinfra" pyinf = "pyinfra --dry" if args.dry_run else "pyinfra"
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploypy}" cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploy_path}"
out.check_call(cmd, env=env) out.check_call(cmd, env=env)
@@ -122,7 +122,7 @@ def test_cmd(args, out):
pytest_path = shutil.which("pytest") pytest_path = shutil.which("pytest")
ret = out.run_ret( ret = out.run_ret(
[pytest_path, "tests/", "-n4", "-rs", "-x", "-vrx", "--durations=5"] [pytest_path, "cmdeploy/src/", "-n4", "-rs", "-x", "-vrx", "--durations=5"]
) )
return ret return ret
@@ -147,11 +147,7 @@ def fmt_cmd_options(parser):
def fmt_cmd(args, out): def fmt_cmd(args, out):
"""Run formattting fixes (fuff and black) on all chatmail source code.""" """Run formattting fixes (fuff and black) on all chatmail source code."""
chatmaild = importlib.resources.files("chatmaild") sources = [str(importlib.resources.files(x)) for x in ("chatmaild", "cmdeploy")]
deploy_chatmail = importlib.resources.files("deploy_chatmail")
tests = deploy_chatmail.joinpath("../../../tests")
sources = list(str(x) for x in [chatmaild, deploy_chatmail, tests])
black_args = [shutil.which("black")] black_args = [shutil.which("black")]
ruff_args = [shutil.which("ruff")] ruff_args = [shutil.which("ruff")]
@@ -174,9 +170,10 @@ def fmt_cmd(args, out):
def bench_cmd(args, out): def bench_cmd(args, out):
"""Run benchmarks against an online chatmail instance.""" """Run benchmarks against an online chatmail instance."""
pytest_path = shutil.which("pytest") args = ["pytest", "--pyargs", "cmdeploy.tests.online.benchmark", "-vrx"]
benchmark = "tests/online/benchmark.py" cmdstring = " ".join(args)
subprocess.check_call([pytest_path, benchmark, "-vrx"]) out.green(f"[$ {cmdstring}]")
subprocess.check_call(args)
def webdev_cmd(args, out): def webdev_cmd(args, out):

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,6 +1,6 @@
import os import os
import pyinfra import pyinfra
from deploy_chatmail import deploy_chatmail from cmdeploy import deploy_chatmail
def main(): def main():

View File

View File

@@ -1,4 +1,4 @@
from deploy_chatmail.genqr import gen_qr_png_data from cmdeploy.genqr import gen_qr_png_data
def test_gen_qr_png_data(maildomain): def test_gen_qr_png_data(maildomain):

View File

@@ -38,7 +38,7 @@ def pytest_runtest_setup(item):
@pytest.fixture @pytest.fixture
def chatmail_config(pytestconfig): def chatmail_config(pytestconfig):
current = basedir = Path() current = basedir = Path().resolve()
while 1: while 1:
path = current.joinpath("chatmail.ini").resolve() path = current.joinpath("chatmail.ini").resolve()
if path.exists(): if path.exists():

View File

@@ -1,7 +1,7 @@
import os import os
import pytest import pytest
from deploy_chatmail.cmdeploy import get_parser, main from cmdeploy.cmdeploy import get_parser, main
from chatmaild.config import read_config from chatmaild.config import read_config

View File

@@ -1,10 +1,10 @@
import importlib.resources import importlib.resources
from deploy_chatmail.www import build_webpages from cmdeploy.www import build_webpages
def test_build_webpages(tmp_path, make_config): def test_build_webpages(tmp_path, make_config):
pkgroot = importlib.resources.files("deploy_chatmail") pkgroot = importlib.resources.files("cmdeploy")
src_dir = pkgroot.joinpath("../../../www/src").resolve() src_dir = pkgroot.joinpath("../../../www/src").resolve()
assert src_dir.exists(), src_dir assert src_dir.exists(), src_dir
config = make_config("chat.example.org") config = make_config("chat.example.org")

View File

@@ -2,8 +2,8 @@
set -e set -e
python3 -m venv venv python3 -m venv venv
venv/bin/pip install -e deploy-chatmail
venv/bin/pip install -e chatmaild venv/bin/pip install -e chatmaild
venv/bin/pip install -e cmdeploy
source venv/bin/activate source venv/bin/activate
echo activated 'venv' python virtualenv environment containing "cmdeploy" tool echo activated 'venv' python virtualenv environment containing "cmdeploy" tool