diff --git a/README.md b/README.md index 4a75b92..83496e1 100644 --- a/README.md +++ b/README.md @@ -155,16 +155,47 @@ To backup your data: 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 diff --git a/RUNNING.md b/RUNNING.md index 9c37f3d..02c80c4 100644 --- a/RUNNING.md +++ b/RUNNING.md @@ -48,10 +48,22 @@ pkill -f "python app.py" - **Port**: 5000 (configurable in app.py) - **Virtual Environment**: `.venv/` (created with uv) -## Troubleshooting -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` +## Running Tests -Enjoy managing your tablets! 📱💻 \ No newline at end of file +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.