-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathtest_cli_config.py
More file actions
57 lines (44 loc) · 1.5 KB
/
test_cli_config.py
File metadata and controls
57 lines (44 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import configparser
from pathlib import Path
import ghstack.cli
from click.testing import CliRunner
def read_config(path: Path) -> configparser.ConfigParser:
parser = configparser.ConfigParser()
parser.read(path)
return parser
def test_config_command() -> None:
runner = CliRunner()
with runner.isolated_filesystem():
config_path = Path.cwd() / ".ghstackrc"
env = {"GHSTACKRC_PATH": str(config_path)}
result = runner.invoke(
ghstack.cli.main,
["config", "automsg"],
env=env,
)
assert result.exit_code == 1
assert "automsg is not set" in result.output
result = runner.invoke(
ghstack.cli.main,
["config", "automsg", "claude"],
env=env,
)
assert result.exit_code == 0
parser = read_config(config_path)
assert parser.get("ghstack", "automsg") == "claude"
result = runner.invoke(
ghstack.cli.main,
["config", "automsg", "codex", "--model", "gpt-5.4"],
env=env,
)
assert result.exit_code == 0
parser = read_config(config_path)
assert parser.get("ghstack", "automsg") == "codex --model gpt-5.4"
result = runner.invoke(
ghstack.cli.main,
["config", "--unset", "automsg"],
env=env,
)
assert result.exit_code == 0
parser = read_config(config_path)
assert not parser.has_option("ghstack", "automsg")