get2knowio / get2knowio/maverick
test: add PermissionError coverage for flight-plan create command
- Dominant language
- Python
- Stars
- 4
- Forks
- 0
- Avg merge
- 17h 37m
- Merged PRs (30d)
- 7
Description
## Context
The `maverick flight-plan create` command (added in #040) now handles `PermissionError` from both `Path.mkdir()` and `Path.write_text()` with a Rich-formatted error message and exit code 1. However, no unit test was written to verify this behaviour.
## Missing coverage
`tests/unit/cli/commands/flight_plan/test_create.py` has no test for:
- Writing to a read-only output directory → expect exit code 1 + error message
- Writing to a path where the file itself is not writable → expect exit code 1 + error message
## Suggested fix
Add parametrized tests that mock `Path.mkdir` and `Path.write_text` to raise `PermissionError` and assert:
1. Exit code is 1
2. The error output contains a user-friendly message (not a raw traceback)
```python
from unittest.mock import patch
def test_create_permission_error_on_mkdir(cli_runner, tmp_path):
with patch("maverick.cli.commands.flight_plan.create.Path.mkdir", side_effect=PermissionError("denied")):
result = cli_runner.invoke(flight_plan, ["create", "my-plan", "--output-dir", str(tmp_path)])
assert result.exit_code == 1
assert "Permission denied" in result.output or "permission" in result.output.lower()
```
## Origin
Flagged during code review of branch `040-flight-plan-cli` (spec compliance review, severity MEDIUM).
Contributor guide
Research direction
Start in tests/unit/cli/commands/flight_plan/test_create.py and read the existing create-command tests and fixtures. Run the focused test file, then add coverage for PermissionError from Path.mkdir and Path.write_text, checking exit code 1 and a user-friendly error rather than a traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100