Spaces:
Sleeping
Sleeping
| # DB Service - Quick Start | |
| ## Run Tests | |
| ```bash | |
| # Install test dependencies | |
| pip install pytest pytest-asyncio httpx | |
| # Run all tests | |
| ADMIN_EMAILS="admin@example.com" pytest tests/test_db_service.py -v | |
| # Run specific test | |
| pytest tests/test_db_service.py::TestPermissions::test_user_can_read_own_data -v | |
| # Run with coverage | |
| pytest tests/test_db_service.py --cov=services/db_service --cov-report=html -v | |
| ``` | |
| ## Start Application | |
| ```bash | |
| # Development (reset DB on startup) | |
| RESET_DB=true ADMIN_EMAILS="your@email.com" python app.py | |
| # Production (preserve DB) | |
| ADMIN_EMAILS="admin@example.com" python app.py | |
| ``` | |
| ## Verify Integration | |
| Check startup logs for: | |
| ``` | |
| β DB Service configured | |
| β Database initialized | |
| β Database reset complete (if RESET_DB=true) | |
| ``` | |
| ## Test Endpoints | |
| ```bash | |
| # As regular user | |
| curl -X GET http://localhost:8000/gemini/jobs \ | |
| -H "Authorization: Bearer <user_token>" | |
| # As admin | |
| curl -X GET http://localhost:8000/blink/audit-logs \ | |
| -H "Authorization: Bearer <admin_token>" | |
| ``` | |
| ## Troubleshooting | |
| **Config not registered:** | |
| ``` | |
| RuntimeError: DBServiceConfig not registered! | |
| ``` | |
| β Ensure `register_db_service_config()` is called in app startup | |
| **Module not found:** | |
| ``` | |
| ModuleNotFoundError: No module named 'services.db_service' | |
| ``` | |
| β Verify `__init__.py` exists in `services/db_service/` | |
| **Permission denied:** | |
| ``` | |
| 403 Forbidden: Only administrators can... | |
| ``` | |
| β Check `ADMIN_EMAILS` environment variable | |
| ## Success Indicators | |
| β All files compile without errors | |
| β Application starts successfully | |
| β Database tables created | |
| β Tests pass | |
| β Endpoints return data correctly | |
| β User isolation working (users see only own data) | |
| β Admin access working (admins see all data) | |