|
15 | 15 | import pathlib
|
16 | 16 |
|
17 | 17 |
|
| 18 | +class ConvertTestFixture(t.NamedTuple): |
| 19 | + """Test fixture for tmuxp convert command tests.""" |
| 20 | + |
| 21 | + test_id: str |
| 22 | + cli_args: list[str] |
| 23 | + |
| 24 | + |
| 25 | +class ConvertJsonTestFixture(t.NamedTuple): |
| 26 | + """Test fixture for tmuxp convert json command tests.""" |
| 27 | + |
| 28 | + test_id: str |
| 29 | + cli_args: list[str] |
| 30 | + |
| 31 | + |
| 32 | +CONVERT_TEST_FIXTURES: list[ConvertTestFixture] = [ |
| 33 | + ConvertTestFixture( |
| 34 | + test_id="convert_current_dir", |
| 35 | + cli_args=["convert", "."], |
| 36 | + ), |
| 37 | + ConvertTestFixture( |
| 38 | + test_id="convert_yaml_file", |
| 39 | + cli_args=["convert", ".tmuxp.yaml"], |
| 40 | + ), |
| 41 | + ConvertTestFixture( |
| 42 | + test_id="convert_yaml_file_auto_confirm", |
| 43 | + cli_args=["convert", ".tmuxp.yaml", "-y"], |
| 44 | + ), |
| 45 | + ConvertTestFixture( |
| 46 | + test_id="convert_yml_file", |
| 47 | + cli_args=["convert", ".tmuxp.yml"], |
| 48 | + ), |
| 49 | + ConvertTestFixture( |
| 50 | + test_id="convert_yml_file_auto_confirm", |
| 51 | + cli_args=["convert", ".tmuxp.yml", "-y"], |
| 52 | + ), |
| 53 | +] |
| 54 | + |
| 55 | + |
| 56 | +CONVERT_JSON_TEST_FIXTURES: list[ConvertJsonTestFixture] = [ |
| 57 | + ConvertJsonTestFixture( |
| 58 | + test_id="convert_json_current_dir", |
| 59 | + cli_args=["convert", "."], |
| 60 | + ), |
| 61 | + ConvertJsonTestFixture( |
| 62 | + test_id="convert_json_file", |
| 63 | + cli_args=["convert", ".tmuxp.json"], |
| 64 | + ), |
| 65 | + ConvertJsonTestFixture( |
| 66 | + test_id="convert_json_file_auto_confirm", |
| 67 | + cli_args=["convert", ".tmuxp.json", "-y"], |
| 68 | + ), |
| 69 | +] |
| 70 | + |
| 71 | + |
18 | 72 | @pytest.mark.parametrize(
|
19 |
| - "cli_args", |
20 |
| - [ |
21 |
| - (["convert", "."]), |
22 |
| - (["convert", ".tmuxp.yaml"]), |
23 |
| - (["convert", ".tmuxp.yaml", "-y"]), |
24 |
| - (["convert", ".tmuxp.yml"]), |
25 |
| - (["convert", ".tmuxp.yml", "-y"]), |
26 |
| - ], |
| 73 | + list(ConvertTestFixture._fields), |
| 74 | + CONVERT_TEST_FIXTURES, |
| 75 | + ids=[test.test_id for test in CONVERT_TEST_FIXTURES], |
27 | 76 | )
|
28 | 77 | def test_convert(
|
| 78 | + test_id: str, |
29 | 79 | cli_args: list[str],
|
30 | 80 | tmp_path: pathlib.Path,
|
31 | 81 | monkeypatch: pytest.MonkeyPatch,
|
@@ -58,14 +108,12 @@ def test_convert(
|
58 | 108 |
|
59 | 109 |
|
60 | 110 | @pytest.mark.parametrize(
|
61 |
| - "cli_args", |
62 |
| - [ |
63 |
| - (["convert", "."]), |
64 |
| - (["convert", ".tmuxp.json"]), |
65 |
| - (["convert", ".tmuxp.json", "-y"]), |
66 |
| - ], |
| 111 | + list(ConvertJsonTestFixture._fields), |
| 112 | + CONVERT_JSON_TEST_FIXTURES, |
| 113 | + ids=[test.test_id for test in CONVERT_JSON_TEST_FIXTURES], |
67 | 114 | )
|
68 | 115 | def test_convert_json(
|
| 116 | + test_id: str, |
69 | 117 | cli_args: list[str],
|
70 | 118 | tmp_path: pathlib.Path,
|
71 | 119 | monkeypatch: pytest.MonkeyPatch,
|
|
0 commit comments