Skip to content

Commit 0494424

Browse files
committed
refactor(tests): convert test_import.py tests to use NamedTuple fixtures
1 parent 0ab0973 commit 0494424

File tree

1 file changed

+83
-31
lines changed

1 file changed

+83
-31
lines changed

tests/cli/test_import.py

+83-31
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,28 @@
1515
import pathlib
1616

1717

18-
@pytest.mark.parametrize("cli_args", [(["import"])])
18+
class ImportTestFixture(t.NamedTuple):
19+
"""Test fixture for basic tmuxp import command tests."""
20+
21+
test_id: str
22+
cli_args: list[str]
23+
24+
25+
IMPORT_TEST_FIXTURES: list[ImportTestFixture] = [
26+
ImportTestFixture(
27+
test_id="basic_import",
28+
cli_args=["import"],
29+
),
30+
]
31+
32+
33+
@pytest.mark.parametrize(
34+
list(ImportTestFixture._fields),
35+
IMPORT_TEST_FIXTURES,
36+
ids=[test.test_id for test in IMPORT_TEST_FIXTURES],
37+
)
1938
def test_import(
39+
test_id: str,
2040
cli_args: list[str],
2141
tmp_path: pathlib.Path,
2242
monkeypatch: pytest.MonkeyPatch,
@@ -29,24 +49,40 @@ def test_import(
2949
assert "teamocil" in result.out
3050

3151

52+
class ImportTeamocilTestFixture(t.NamedTuple):
53+
"""Test fixture for tmuxp import teamocil command tests."""
54+
55+
test_id: str
56+
cli_args: list[str]
57+
inputs: list[str]
58+
59+
60+
IMPORT_TEAMOCIL_TEST_FIXTURES: list[ImportTeamocilTestFixture] = [
61+
ImportTeamocilTestFixture(
62+
test_id="import_teamocil_config_file",
63+
cli_args=["import", "teamocil", "./.teamocil/config.yaml"],
64+
inputs=["\n", "y\n", "./la.yaml\n", "y\n"],
65+
),
66+
ImportTeamocilTestFixture(
67+
test_id="import_teamocil_config_file_exists",
68+
cli_args=["import", "teamocil", "./.teamocil/config.yaml"],
69+
inputs=["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
70+
),
71+
ImportTeamocilTestFixture(
72+
test_id="import_teamocil_config_name",
73+
cli_args=["import", "teamocil", "config"],
74+
inputs=["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
75+
),
76+
]
77+
78+
3279
@pytest.mark.parametrize(
33-
("cli_args", "inputs"),
34-
[
35-
(
36-
["import", "teamocil", "./.teamocil/config.yaml"],
37-
["\n", "y\n", "./la.yaml\n", "y\n"],
38-
),
39-
(
40-
["import", "teamocil", "./.teamocil/config.yaml"],
41-
["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
42-
),
43-
(
44-
["import", "teamocil", "config"],
45-
["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
46-
),
47-
],
80+
list(ImportTeamocilTestFixture._fields),
81+
IMPORT_TEAMOCIL_TEST_FIXTURES,
82+
ids=[test.test_id for test in IMPORT_TEAMOCIL_TEST_FIXTURES],
4883
)
4984
def test_import_teamocil(
85+
test_id: str,
5086
cli_args: list[str],
5187
inputs: list[str],
5288
tmp_path: pathlib.Path,
@@ -76,24 +112,40 @@ def test_import_teamocil(
76112
assert new_config_yaml.exists()
77113

78114

115+
class ImportTmuxinatorTestFixture(t.NamedTuple):
116+
"""Test fixture for tmuxp import tmuxinator command tests."""
117+
118+
test_id: str
119+
cli_args: list[str]
120+
inputs: list[str]
121+
122+
123+
IMPORT_TMUXINATOR_TEST_FIXTURES: list[ImportTmuxinatorTestFixture] = [
124+
ImportTmuxinatorTestFixture(
125+
test_id="import_tmuxinator_config_file",
126+
cli_args=["import", "tmuxinator", "./.tmuxinator/config.yaml"],
127+
inputs=["\n", "y\n", "./la.yaml\n", "y\n"],
128+
),
129+
ImportTmuxinatorTestFixture(
130+
test_id="import_tmuxinator_config_file_exists",
131+
cli_args=["import", "tmuxinator", "./.tmuxinator/config.yaml"],
132+
inputs=["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
133+
),
134+
ImportTmuxinatorTestFixture(
135+
test_id="import_tmuxinator_config_name",
136+
cli_args=["import", "tmuxinator", "config"],
137+
inputs=["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
138+
),
139+
]
140+
141+
79142
@pytest.mark.parametrize(
80-
("cli_args", "inputs"),
81-
[
82-
(
83-
["import", "tmuxinator", "./.tmuxinator/config.yaml"],
84-
["\n", "y\n", "./la.yaml\n", "y\n"],
85-
),
86-
(
87-
["import", "tmuxinator", "./.tmuxinator/config.yaml"],
88-
["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
89-
),
90-
(
91-
["import", "tmuxinator", "config"],
92-
["\n", "y\n", "./exists.yaml\n", "./la.yaml\n", "y\n"],
93-
),
94-
],
143+
list(ImportTmuxinatorTestFixture._fields),
144+
IMPORT_TMUXINATOR_TEST_FIXTURES,
145+
ids=[test.test_id for test in IMPORT_TMUXINATOR_TEST_FIXTURES],
95146
)
96147
def test_import_tmuxinator(
148+
test_id: str,
97149
cli_args: list[str],
98150
inputs: list[str],
99151
tmp_path: pathlib.Path,

0 commit comments

Comments
 (0)