wiki: document testing — coverage table, requirements, how to add new tests
parent
897e22f262
commit
e7b4613471
1 changed files with 60 additions and 0 deletions
|
|
@ -89,6 +89,57 @@ git branch -d <branch>
|
|||
|
||||
---
|
||||
|
||||
## Testing
|
||||
|
||||
### Running tests
|
||||
|
||||
```bash
|
||||
python3 -m unittest discover -s tests/ -v
|
||||
```
|
||||
|
||||
No dependencies needed — the test suite uses stdlib `unittest` only.
|
||||
|
||||
### Test coverage
|
||||
|
||||
Tests live in `tests/`, one file per module:
|
||||
|
||||
| Test file | Module covered |
|
||||
|---|---|
|
||||
| `test_cache.py` | `cache.py` — entry validation, confidence fields, investigation IDs |
|
||||
| `test_filetypes.py` | `filetypes.py` — extension classification, `classify_files`, `summarize_categories` |
|
||||
| `test_code.py` | `code.py` — language detection, LOC counting, large file detection |
|
||||
| `test_disk.py` | `disk.py` — disk usage parsing, `_human_size`, `top_directories` |
|
||||
| `test_recency.py` | `recency.py` — recent file detection, output parsing |
|
||||
| `test_tree.py` | `tree.py` — tree building, rendering, hidden/exclude logic |
|
||||
| `test_report.py` | `report.py` — `format_flags`, `format_report`, all sections |
|
||||
| `test_capabilities.py` | `capabilities.py` — `_check_package` |
|
||||
|
||||
Modules **not covered** (exempt from unit testing):
|
||||
|
||||
| Module | Reason |
|
||||
|---|---|
|
||||
| `ai.py` | Requires live Anthropic API |
|
||||
| `ast_parser.py` | Requires tree-sitter optional dep |
|
||||
| `watch.py` | Stateful filesystem event loop |
|
||||
| `prompts.py` | String templates with no logic |
|
||||
|
||||
### Test requirements
|
||||
|
||||
- Every change to a covered module must include or update its tests
|
||||
- All 129 tests must pass before merging to main
|
||||
- Subprocess-heavy functions (`wc`, `du`, `find`, `file`) are tested via `unittest.mock` — no real filesystem calls needed
|
||||
- Tests that require real filesystem interaction use `tempfile.mkdtemp()` and clean up automatically
|
||||
|
||||
### Adding tests for new modules
|
||||
|
||||
1. Create `tests/test_<module>.py`
|
||||
2. Import from `luminos_lib.<module>`
|
||||
3. Use `unittest.TestCase` subclasses
|
||||
4. Mock subprocess calls with `unittest.mock.patch("subprocess.run", ...)`
|
||||
5. Add the new file to the table above
|
||||
|
||||
---
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
| Context | Convention | Example |
|
||||
|
|
@ -120,6 +171,15 @@ luminos/
|
|||
│ ├── report.py terminal report formatter
|
||||
│ ├── tree.py directory tree
|
||||
│ └── watch.py watch mode
|
||||
├── tests/
|
||||
│ ├── test_cache.py
|
||||
│ ├── test_capabilities.py
|
||||
│ ├── test_code.py
|
||||
│ ├── test_disk.py
|
||||
│ ├── test_filetypes.py
|
||||
│ ├── test_recency.py
|
||||
│ ├── test_report.py
|
||||
│ └── test_tree.py
|
||||
├── docs/wiki/ local clone of Forgejo wiki (gitignored)
|
||||
├── setup_env.sh venv + AI dep setup script
|
||||
├── CLAUDE.md Claude Code context (thin — points to wiki)
|
||||
|
|
|
|||
Loading…
Reference in a new issue