Skip to content

Commit 59e5dea

Browse files
committed
fix: make "cmdeploy test --config ..." work, without requiring or implicitely falling back to a "chatmail.ini" in parent dirs
1 parent d7d89d6 commit 59e5dea

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

cmdeploy/src/cmdeploy/cmdeploy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def test_cmd(args, out):
209209
"""Run local and online tests for chatmail deployment."""
210210

211211
env = os.environ.copy()
212+
env["CHATMAIL_INI"] = str(args.inipath.absolute())
212213
if args.ssh_host:
213214
env["CHATMAIL_SSH"] = args.ssh_host
214215

cmdeploy/src/cmdeploy/tests/plugin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def pytest_runtest_setup(item):
3535

3636

3737
def _get_chatmail_config():
38+
inipath = os.environ.get("CHATMAIL_INI")
39+
if inipath:
40+
path = Path(inipath).resolve()
41+
return read_config(path), path
42+
3843
current = Path().resolve()
3944
while 1:
4045
path = current.joinpath("chatmail.ini").resolve()

cmdeploy/src/cmdeploy/tests/test_cmdeploy.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,19 @@ def test_parser(self, capsys):
2323
run = parser.parse_args(["run"])
2424
assert init and run
2525

26-
def test_init_not_overwrite(self, capsys):
27-
assert main(["init", "chat.example.org"]) == 0
26+
def test_init_not_overwrite(self, capsys, tmp_path, monkeypatch):
27+
monkeypatch.delenv("CHATMAIL_INI", raising=False)
28+
inipath = tmp_path / "chatmail.ini"
29+
args = ["init", "--config", str(inipath), "chat.example.org"]
30+
assert main(args) == 0
2831
capsys.readouterr()
2932

30-
assert main(["init", "chat.example.org"]) == 1
33+
assert main(args) == 1
3134
out, err = capsys.readouterr()
3235
assert "path exists" in out.lower()
3336

34-
assert main(["init", "chat.example.org", "--force"]) == 0
37+
args.insert(1, "--force")
38+
assert main(args) == 0
3539
out, err = capsys.readouterr()
3640
assert "deleting config file" in out.lower()
3741

0 commit comments

Comments
 (0)