Add 87 unit tests for admin endpoints (24% → 100% coverage), fix conftest.py fixtures
Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/d17e4b46-03fd-450a-af61-1870011377b4 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -19,10 +19,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- **Admin endpoint test coverage**: Added 87 unit tests for `admin.py` covering all 17 endpoints (stats, user CRUD, plan CRUD, notification config CRUD, notification testing, processing runs/logs with GDPR masking and pagination). Coverage improved from 24% to 100%.
|
||||
- **Domain-based logo fallback for mail accounts**: `ProviderLogoBanner` now shows provider logos even for accounts that have no `provider_name` set, by extracting the domain from the email address and matching it against a new `DOMAIN_ICON_MAP`. Covers Gmail, GMX, WEB.DE, Yahoo Mail, AOL, T-Online, Outlook/Hotmail, IONOS, Freenet, iCloud, Posteo, and Proton Mail.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Test fixtures**: Fixed `conftest.py` admin user fixture using non-existent `is_admin`/`is_verified` fields (should be `is_superuser`), and JWT `sub` claim using email instead of user ID.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Convert `frontend/jest.config.js` to `jest.config.mjs` using ES module `import`/`export` syntax to resolve ESLint `@typescript-eslint/no-require-imports` error.
|
||||
- Suppress noisy `ignored untagged response` INFO log lines from `aioimaplib` in Celery workers by setting the `aioimaplib` logger to WARNING level in `celery_app.py`.
|
||||
- Eliminate `file_cache is only supported with oauth2client<4.0.0` warnings by passing `cache_discovery=False` to `googleapiclient.discovery.build()` in `gmail_service.py`.
|
||||
|
||||
@@ -82,7 +82,6 @@ async def test_user(db_session: AsyncSession) -> User:
|
||||
email="test@example.com",
|
||||
hashed_password=get_password_hash("testpassword123"),
|
||||
is_active=True,
|
||||
is_verified=True,
|
||||
)
|
||||
db_session.add(user)
|
||||
await db_session.commit()
|
||||
@@ -97,8 +96,7 @@ async def test_admin_user(db_session: AsyncSession) -> User:
|
||||
email="admin@example.com",
|
||||
hashed_password=get_password_hash("adminpassword123"),
|
||||
is_active=True,
|
||||
is_verified=True,
|
||||
is_admin=True,
|
||||
is_superuser=True,
|
||||
)
|
||||
db_session.add(user)
|
||||
await db_session.commit()
|
||||
@@ -109,14 +107,14 @@ async def test_admin_user(db_session: AsyncSession) -> User:
|
||||
@pytest.fixture
|
||||
def auth_headers(test_user: User) -> dict:
|
||||
"""Generate authentication headers for test user"""
|
||||
access_token = create_access_token(data={"sub": test_user.email})
|
||||
access_token = create_access_token(data={"sub": str(test_user.id)})
|
||||
return {"Authorization": f"Bearer {access_token}"}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin_auth_headers(test_admin_user: User) -> dict:
|
||||
"""Generate authentication headers for admin user"""
|
||||
access_token = create_access_token(data={"sub": test_admin_user.email})
|
||||
access_token = create_access_token(data={"sub": str(test_admin_user.id)})
|
||||
return {"Authorization": f"Bearer {access_token}"}
|
||||
|
||||
|
||||
@@ -131,8 +129,7 @@ def user_factory(db_session: AsyncSession):
|
||||
email: str = None,
|
||||
password: str = "testpassword123",
|
||||
is_active: bool = True,
|
||||
is_verified: bool = True,
|
||||
is_admin: bool = False,
|
||||
is_superuser: bool = False,
|
||||
) -> User:
|
||||
if email is None:
|
||||
import uuid
|
||||
@@ -143,8 +140,7 @@ def user_factory(db_session: AsyncSession):
|
||||
email=email,
|
||||
hashed_password=get_password_hash(password),
|
||||
is_active=is_active,
|
||||
is_verified=is_verified,
|
||||
is_admin=is_admin,
|
||||
is_superuser=is_superuser,
|
||||
)
|
||||
db_session.add(user)
|
||||
await db_session.commit()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -115,6 +115,7 @@ Comprehensive task breakdown for repository improvements and production readines
|
||||
- [x] Write unit tests for schemas and validation
|
||||
- [x] Write unit tests for application factory and core endpoints
|
||||
- [x] Reach 50%+ test coverage (currently 59%)
|
||||
- [x] Write unit tests for admin endpoints (87 tests, 100% coverage on admin.py)
|
||||
|
||||
### In Progress 🔨
|
||||
- [ ] Write unit tests for authentication (target 80%+ coverage)
|
||||
|
||||
Reference in New Issue
Block a user