test(P14.1): add comprehensive backend API test suite

Add 134 tests as independent test project:
- test_auth.py (5): Login, JWT, protected endpoints
- test_users.py (8): User CRUD, permissions
- test_projects.py (8): Project CRUD, ownership
- test_milestones.py (7): Milestone CRUD, filtering
- test_tasks.py (8): Task CRUD, filtering
- test_comments.py (5): Comment CRUD, permissions
- test_roles.py (9): Role/permission management
- test_milestone_actions.py (17): Milestone state machine
- test_task_transitions.py (34): Task state machine
- test_propose.py (19): Propose CRUD, lifecycle
- test_misc.py (14): Notifications, activity, API keys, dashboard

Setup:
- conftest.py: SQLite in-memory DB, fixtures
- requirements.txt: Dependencies
- pyproject.toml: Pytest config
- README.md: Documentation
This commit is contained in:
zhi
2026-03-19 12:43:44 +00:00
parent 477419cb57
commit 5f6a3dffe4
29 changed files with 3117 additions and 0 deletions

View File

@@ -1 +1,52 @@
# HarborForge.Backend.Test
Independent test suite for HarborForge.Backend.
## Setup
```bash
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
```
## Run Tests
```bash
# Run all tests
pytest
# Run specific test file
pytest tests/test_auth.py
# Run with verbose output
pytest -v
# Run with coverage (requires pytest-cov)
pytest --cov=../HarborForge.Backend/app --cov-report=html
```
## Test Structure
| File | Tests | Coverage |
|------|-------|----------|
| `test_auth.py` | 5 | Login, JWT, protected endpoints |
| `test_users.py` | 8 | User CRUD, permissions |
| `test_projects.py` | 8 | Project CRUD, ownership |
| `test_milestones.py` | 7 | Milestone CRUD, filtering |
| `test_tasks.py` | 8 | Task CRUD, filtering |
| `test_comments.py` | 5 | Comment CRUD, permissions |
| `test_roles.py` | 9 | Role/permission management |
| `test_milestone_actions.py` | 17 | Milestone state machine actions |
| `test_task_transitions.py` | 34 | Task state machine transitions |
| `test_propose.py` | 19 | Propose CRUD, accept/reject/reopen |
| `test_misc.py` | 14 | Notifications, activity log, API keys, dashboard |
**Total: 134 tests**
## How It Works
Tests import the backend code from `../HarborForge.Backend/` via path manipulation in `conftest.py`. Uses SQLite in-memory database for fast, isolated tests.