From dfe91e2ce14d52a17077752433068c2a370443e7 Mon Sep 17 00:00:00 2001 From: tech Date: Wed, 18 Mar 2026 13:27:44 +0800 Subject: [PATCH] fix: Address plan review feedback - imports and test coverage Co-Authored-By: Claude Opus 4.6 --- .../plans/2026-03-18-config-file-support.md | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/superpowers/plans/2026-03-18-config-file-support.md b/docs/superpowers/plans/2026-03-18-config-file-support.md index 9897860..cb86af5 100644 --- a/docs/superpowers/plans/2026-03-18-config-file-support.md +++ b/docs/superpowers/plans/2026-03-18-config-file-support.md @@ -28,6 +28,13 @@ - Create: `src/zzpyjenkins/config.py` - Create: `tests/test_config.py` +- [ ] **Step 0: Create tests directory** + +```bash +mkdir -p tests +touch tests/__init__.py +``` + - [ ] **Step 1: Write the failing test for load_config with missing file** ```python @@ -98,6 +105,27 @@ def load_config(config_path: Path) -> dict: Run: `uv run pytest tests/test_config.py -v` Expected: PASS +- [ ] **Step 4.5: Add test for invalid TOML syntax** + +```python +# Add to tests/test_config.py +import tempfile + + +def test_load_config_invalid_toml(): + """Test load_config raises error for invalid TOML syntax.""" + with tempfile.NamedTemporaryFile(mode="w", suffix=".toml", delete=False) as f: + f.write("invalid toml [[[[") + temp_path = Path(f.name) + + try: + with pytest.raises(ConfigError) as exc_info: + load_config(temp_path) + assert "Invalid TOML syntax" in str(exc_info.value) + finally: + temp_path.unlink() +``` + - [ ] **Step 5: Commit** ```bash @@ -117,6 +145,9 @@ git commit -m "feat: add config module with load_config function" ```python # Add to tests/test_config.py +# Update import to include get_server_config: +from zzpyjenkins.config import load_config, ConfigError, get_server_config + def test_get_server_config_success(): """Test getting a valid server config.""" @@ -231,6 +262,14 @@ git commit -m "feat: add get_server_config function with validation" ```python # Add to tests/test_config.py +# Update import to include get_default_config_path: +from zzpyjenkins.config import ( + load_config, + ConfigError, + get_server_config, + get_default_config_path, +) + def test_get_default_config_path(): """Test default config path is correct.""" @@ -374,9 +413,7 @@ git commit -m "feat: replace credential options with --server config option" ```python # Add to tests/test_config.py - -import tempfile - +# tempfile is already imported in Task 1 def test_full_config_flow(): """Test complete config loading flow with temp file."""