|
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 | +CONVERT_TEST_FIXTURES: list[ConvertTestFixture] = [ |
| 26 | + ConvertTestFixture( |
| 27 | + test_id="convert_current_dir", |
| 28 | + cli_args=["convert", "."], |
| 29 | + ), |
| 30 | + ConvertTestFixture( |
| 31 | + test_id="convert_yaml_file", |
| 32 | + cli_args=["convert", ".tmuxp.yaml"], |
| 33 | + ), |
| 34 | + ConvertTestFixture( |
| 35 | + test_id="convert_yaml_file_auto_confirm", |
| 36 | + cli_args=["convert", ".tmuxp.yaml", "-y"], |
| 37 | + ), |
| 38 | + ConvertTestFixture( |
| 39 | + test_id="convert_yml_file", |
| 40 | + cli_args=["convert", ".tmuxp.yml"], |
| 41 | + ), |
| 42 | + ConvertTestFixture( |
| 43 | + test_id="convert_yml_file_auto_confirm", |
| 44 | + cli_args=["convert", ".tmuxp.yml", "-y"], |
| 45 | + ), |
| 46 | +] |
| 47 | + |
| 48 | + |
18 | 49 | @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 |
| - ], |
| 50 | + list(ConvertTestFixture._fields), |
| 51 | + CONVERT_TEST_FIXTURES, |
| 52 | + ids=[test.test_id for test in CONVERT_TEST_FIXTURES], |
27 | 53 | )
|
28 | 54 | def test_convert(
|
| 55 | + test_id: str, |
29 | 56 | cli_args: list[str],
|
30 | 57 | tmp_path: pathlib.Path,
|
31 | 58 | monkeypatch: pytest.MonkeyPatch,
|
@@ -57,15 +84,36 @@ def test_convert(
|
57 | 84 | assert tmuxp_json.open().read() == json.dumps({"session_name": "hello"}, indent=2)
|
58 | 85 |
|
59 | 86 |
|
| 87 | +class ConvertJsonTestFixture(t.NamedTuple): |
| 88 | + """Test fixture for tmuxp convert json command tests.""" |
| 89 | + |
| 90 | + test_id: str |
| 91 | + cli_args: list[str] |
| 92 | + |
| 93 | + |
| 94 | +CONVERT_JSON_TEST_FIXTURES: list[ConvertJsonTestFixture] = [ |
| 95 | + ConvertJsonTestFixture( |
| 96 | + test_id="convert_json_current_dir", |
| 97 | + cli_args=["convert", "."], |
| 98 | + ), |
| 99 | + ConvertJsonTestFixture( |
| 100 | + test_id="convert_json_file", |
| 101 | + cli_args=["convert", ".tmuxp.json"], |
| 102 | + ), |
| 103 | + ConvertJsonTestFixture( |
| 104 | + test_id="convert_json_file_auto_confirm", |
| 105 | + cli_args=["convert", ".tmuxp.json", "-y"], |
| 106 | + ), |
| 107 | +] |
| 108 | + |
| 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