fix: Address plan review feedback - imports and test coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 13:27:44 +08:00
parent 3664e98801
commit dfe91e2ce1

View File

@@ -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."""