mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 21:08:03 +00:00
fix tests and run all tests on "cmdeploy test"
This commit is contained in:
@@ -125,7 +125,7 @@ def test_cmd(args, out):
|
|||||||
|
|
||||||
pytest_path = shutil.which("pytest")
|
pytest_path = shutil.which("pytest")
|
||||||
proc3 = subprocess.run(
|
proc3 = subprocess.run(
|
||||||
[pytest_path, "tests/online", "-rs", "-x", "-vrx", "--durations=5"]
|
[pytest_path, "tests/", "-rs", "-x", "-vrx", "--durations=5"]
|
||||||
)
|
)
|
||||||
if any(x.returncode != 0 for x in (proc1, proc2, proc3)):
|
if any(x.returncode != 0 for x in (proc1, proc2, proc3)):
|
||||||
return 1
|
return 1
|
||||||
@@ -239,7 +239,11 @@ def main(args=None):
|
|||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.exit(args.func(args, out, **kwargs))
|
res = args.func(args, out, **kwargs)
|
||||||
|
if res is None:
|
||||||
|
res = 0
|
||||||
|
return res
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
out.red("KeyboardInterrupt")
|
out.red("KeyboardInterrupt")
|
||||||
sys.exit(130)
|
sys.exit(130)
|
||||||
|
|||||||
@@ -1,25 +1,33 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from deploy_chatmail.cmdeploy import get_parser, main
|
from deploy_chatmail.cmdeploy import get_parser, main
|
||||||
from chatmaild.config import read_config
|
from chatmaild.config import read_config
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def _chdir(tmp_path):
|
||||||
|
old = os.getcwd()
|
||||||
|
os.chdir(tmp_path)
|
||||||
|
yield
|
||||||
|
os.chdir(old)
|
||||||
|
|
||||||
|
|
||||||
class TestCmdline:
|
class TestCmdline:
|
||||||
def test_parser(self, capsys):
|
def test_parser(self, capsys):
|
||||||
parser = get_parser()
|
parser = get_parser()
|
||||||
parser.parse_args([])
|
parser.parse_args([])
|
||||||
init = parser.parse_args(["init", "chat.example.org"])
|
init = parser.parse_args(["init", "chat.example.org"])
|
||||||
update = parser.parse_args(["install"])
|
run = parser.parse_args(["run"])
|
||||||
assert init and update
|
assert init and run
|
||||||
|
|
||||||
def test_init(self, tmpdir):
|
def test_init(self, tmp_path):
|
||||||
tmpdir.chdir()
|
|
||||||
main(["init", "chat.example.org"])
|
main(["init", "chat.example.org"])
|
||||||
inipath = tmpdir.join("chatmail.ini")
|
inipath = tmp_path.joinpath("chatmail.ini")
|
||||||
config = read_config(inipath.strpath)
|
config = read_config(inipath.strpath)
|
||||||
assert config.mailname == "chat.example.org"
|
assert config.mailname == "chat.example.org"
|
||||||
|
|
||||||
def test_init_not_overwrite(self, tmpdir):
|
def test_init_not_overwrite(self):
|
||||||
tmpdir.chdir()
|
|
||||||
main(["init", "chat.example.org"])
|
main(["init", "chat.example.org"])
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
main(["init", "chat.example.org"])
|
main(["init", "chat.example.org"])
|
||||||
|
|||||||
Reference in New Issue
Block a user