fix: Address plan review feedback - imports and test coverage
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,13 @@
|
|||||||
- Create: `src/zzpyjenkins/config.py`
|
- Create: `src/zzpyjenkins/config.py`
|
||||||
- Create: `tests/test_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**
|
- [ ] **Step 1: Write the failing test for load_config with missing file**
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@@ -98,6 +105,27 @@ def load_config(config_path: Path) -> dict:
|
|||||||
Run: `uv run pytest tests/test_config.py -v`
|
Run: `uv run pytest tests/test_config.py -v`
|
||||||
Expected: PASS
|
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**
|
- [ ] **Step 5: Commit**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -117,6 +145,9 @@ git commit -m "feat: add config module with load_config function"
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Add to tests/test_config.py
|
# 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():
|
def test_get_server_config_success():
|
||||||
"""Test getting a valid server config."""
|
"""Test getting a valid server config."""
|
||||||
@@ -231,6 +262,14 @@ git commit -m "feat: add get_server_config function with validation"
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Add to tests/test_config.py
|
# 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():
|
def test_get_default_config_path():
|
||||||
"""Test default config path is correct."""
|
"""Test default config path is correct."""
|
||||||
@@ -374,9 +413,7 @@ git commit -m "feat: replace credential options with --server config option"
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Add to tests/test_config.py
|
# Add to tests/test_config.py
|
||||||
|
# tempfile is already imported in Task 1
|
||||||
import tempfile
|
|
||||||
|
|
||||||
|
|
||||||
def test_full_config_flow():
|
def test_full_config_flow():
|
||||||
"""Test complete config loading flow with temp file."""
|
"""Test complete config loading flow with temp file."""
|
||||||
|
|||||||
Reference in New Issue
Block a user