docs: add testing documentation to README and RUNNING.md

- Add Testing section to README with:
  - How to run tests
  - Test structure overview
  - Key edge cases covered
  - Test configuration notes
- Add Running Tests section to RUNNING.md
- Document the 46 unit tests available
This commit is contained in:
ijuanes 2026-06-17 17:10:12 +01:00
parent 83ac67fea2
commit 85978a710f
2 changed files with 56 additions and 13 deletions

View file

@ -155,16 +155,47 @@ To backup your data:
cp tablets.db tablets_backup_$(date +%Y%m%d).db cp tablets.db tablets_backup_$(date +%Y%m%d).db
``` ```
## Version Control ## Testing
This project uses Git for version control with the following structure: The project includes a comprehensive unit test suite with **46 tests** covering core functionality and edge cases.
### Running Tests
```bash
# Install test dependencies (if not already installed)
source .venv/bin/activate
uv pip install pytest pytest-cov
# Run all tests
python3 -m pytest tests/ -v
# Run with coverage report
python3 -m pytest tests/ --cov=./ --cov-report=term-missing
```
### Test Structure
| File | Tests | Coverage |
|------|-------|----------|
| `tests/test_core.py` | 21 | Core operations (tablet, user, loan CRUD) |
| `tests/test_edge_cases.py` | 14 | Edge cases (duplicates, invalid IDs, etc.) |
| `tests/test_minimal_app.py` | 11 | Application function tests |
### Key Edge Cases Covered
- Loan a device that's already loaned (prevents double-loaning)
- Return a non-existent loan (handles gracefully)
- Duplicate serial numbers (rejected at database level)
- Duplicate user identifications (rejected at database level)
- Invalid tablet/user IDs (validated before operations)
- Multiple loans per user (one-to-many relationship)
- Loan-return-loan sequence (device lifecycle)
### Test Configuration
Tests use isolated temporary databases and automatically clean up after each test run. No impact on production data.
- `master` - Production-ready releases
- `develop` - Integration branch for features
- `feature/*` - Individual feature branches
- `hotfix/*` - Urgent bug fixes
See `CONTRIBUTING.md` for detailed workflow and commit conventions.
## License ## License

View file

@ -48,10 +48,22 @@ pkill -f "python app.py"
- **Port**: 5000 (configurable in app.py) - **Port**: 5000 (configurable in app.py)
- **Virtual Environment**: `.venv/` (created with uv) - **Virtual Environment**: `.venv/` (created with uv)
## Troubleshooting ## Running Tests
If you have issues:
1. Check if the server is running: `ps aux | grep app.py`
2. Check the database: `sqlite3 tablets.db`
3. Restart the server: `source .venv/bin/activate && python app.py`
Enjoy managing your tablets! 📱💻 The project includes 46 unit tests for verifying functionality:
```bash
# Run all tests
python3 -m pytest tests/ -v
# Run with coverage
python3 -m pytest tests/ --cov=./ --cov-report=term-missing
```
Tests cover:
- Core CRUD operations for tablets, users, and loans
- Edge cases (duplicates, invalid IDs, already loaned devices)
- Application function testing
- Non-loanable device management
All tests use isolated temporary databases and do not affect production data.