feat: update M2/M3 milestones to include testing infrastructure

M2 (Backend):
- Add tests/ folder with pytest test files
- Add pytest.ini for test configuration and coverage
- Update scoring to require unit tests (Score 4+)

M3 (Frontend):
- Add tests/ folder with Vitest component unit tests
- Add playwright/e2e/ folder with E2E Playwright tests
- Add @playwright/test dependency and configuration
- Update scoring to require both unit and E2E tests (Score 5)

README.md updated with all milestone links and test requirements
This commit is contained in:
Daniel Samson committed 2026-10-29 15:54:10 +00:00
1 parent d66fe178c3
commit 85490bc0a2
5 files changed
+216 -65

No files matched your search

+66 -3
View File
@@ -19,11 +19,17 @@ Create the backend infrastructure for **newzy** news web application using Pytho
│ │ └── __init__.py
│ ├── schemas/
│ │ └── __init__.py
│ ├── tests/
│ │ ├── conftest.py
│ │ ├── test_health.py
│ │ ├── test_version.py
│ │ └── test_models.py
│ ├── main.py
│ ├── config.py
│ ├── requirements.txt
│ ├── Dockerfile
│ ├── .gitignore
│ ├── pytest.ini
│ └── README.md
```
@@ -41,6 +47,7 @@ Create the backend infrastructure for **newzy** news web application using Pytho
- SQLAlchemy
- pydantic
- python-multipart
- pytest and pytest-asyncio for testing
6. Create initial database models for:
- Article (title, content, author_id, category_id, created_at, published)
@@ -60,7 +67,15 @@ Create the backend infrastructure for **newzy** news web application using Pytho
- Expose port 8000
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
11. Add docker-compose.yml at project root with backend service
11. Add `pytest.ini` with test configuration and coverage settings
12. Create unit tests in `backend/tests/`:
- Test health endpoint returns 200 OK
- Test version endpoint returns correct format
- Test model instantiation and database operations
- Use pytest fixtures for database setup/teardown
13. Add docker-compose.yml at project root with backend service
Remember: Focus ONLY on backend infrastructure. No frontend implementation required.
@@ -72,7 +87,7 @@ This milestone sets up the FastAPI backend for newzy news application using Pyth
**Target Audience**: Backend developers joining the project who need to understand and extend the API.
**Expected Outcomes**: A containerized FastAPI server with database connectivity, core models defined, and documented endpoints ready for additional features.
**Expected Outcomes**: A containerized FastAPI server with database connectivity, core models defined, documented endpoints, and comprehensive unit tests demonstrating proper implementation.
## Acceptance Criteria
@@ -82,11 +97,13 @@ This milestone sets up the FastAPI backend for newzy news application using Pyth
- [ ] Pydantic schemas implemented for all models
- [ ] Health check endpoint (`GET /health`) returns 200 OK
- [ ] Version endpoint (`GET /api/v1/version`) returns application version
- [ ] `requirements.txt` lists all Python dependencies
- [ ] `requirements.txt` lists all Python dependencies including testing libs
- [ ] Proper error handling with standardized response format
- [ ] `backend/README.md` documents API endpoints with examples
- [ ] `.gitignore` file created with appropriate exclusions
- [ ] `Dockerfile` creates runnable container image
- [ ] Unit tests in `backend/tests/` covering health, version, and models
- [ ] pytest.ini configured for test discovery and coverage
- [ ] Code follows FastAPI and SQLAlchemy best practices
## Technical Details
@@ -102,11 +119,17 @@ project-root/
│ ├── db/
│ ├── models/
│ ├── schemas/
│ ├── tests/
│ │ ├── conftest.py
│ │ ├── test_health.py
│ │ ├── test_version.py
│ │ └── test_models.py
│ ├── main.py
│ ├── config.py
│ ├── requirements.txt
│ ├── Dockerfile
│ ├── .gitignore
│ ├── pytest.ini
│ └── README.md
├── LICENSE # MIT License
├── README.md
@@ -159,6 +182,9 @@ Dockerfile
.idea/
.vscode/
*~
.coverage
htmlcov/
.pytest_cache/
```
### Dockerfile
@@ -181,6 +207,18 @@ EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```
### pytest.ini Configuration
```ini
[pytest]
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
asyncio_mode = auto
addopts = -v --cov=. --cov-report=term-missing
filterwarnings = ignore::DeprecationWarning
```
### docker-compose.yml (project root)
```yaml
version: '3.8'
@@ -196,11 +234,29 @@ services:
- DATABASE_URL=sqlite:///./data/db/newzy.db
```
### Unit Tests Overview
**test_health.py:**
- Test health endpoint returns 200 status code
- Verify response contains expected JSON structure
- Test alternative /api/v1/health path
**test_version.py:**
- Test version endpoint returns valid version string
- Response format validation (e.g., "v0.1.0")
**test_models.py:**
- Test Article model creation and commit to database
- Test Author model creation with unique constraints
- Test Category model slug generation
- Verify foreign key relationships work correctly
### Configuration
- Environment variables for database URL (DATABASE_URL)
- Docker volume configuration: `/data/db` mapped to SQLite file
- CORS enabled for frontend development
- Uvicorn workers configured for production deployment
- Pytest configured for coverage reporting
## QA Notes
@@ -214,18 +270,22 @@ services:
- [ ] No unhandled exceptions in basic operations
- [ ] Docker container builds successfully
- [ ] Container runs and serves endpoints
- [ ] pytest discovers and runs all test files
- [ ] All unit tests pass (100% expected coverage)
### Performance Considerations
- Single-threaded async mode for development (uvicorn workers = 1)
- SQLite file-based storage (no connection pool needed yet)
- Lazy database session management
- Docker Compose enables easy local development setup
- Tests use fast in-memory or temporary database files
### Security Notes
- Password hashing to be implemented in future milestones
- Authentication mechanism TBD
- CORS configuration should be validated before production
- Environment variables for secrets should use .env files
- pytest cache directories excluded from git
### Known Issues / Limitations
- No input validation beyond Pydantic schemas
@@ -233,6 +293,7 @@ services:
- Database schema not yet optimized for performance
- Missing pagination and filtering on article endpoints
- SQLite not suitable for high-concurrency production workloads
- Tests don't cover edge cases or error scenarios extensively
### Success Metrics
- Application starts in under 10 seconds locally
@@ -240,3 +301,5 @@ services:
- All models query successfully without errors
- Docker image builds and runs cleanly
- README examples work as documented
- Unit tests achieve >=70% code coverage on core modules
- All tests complete in under 30 seconds