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:
copilot-swe-agent[bot]
2026-03-29 00:06:02 +00:00
parent c0e2dd22cb
commit da9d822afa
4 changed files with 1214 additions and 9 deletions
+5
View File
@@ -19,10 +19,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### 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. - **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 ### 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. - 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`. - 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`. - 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`.
+5 -9
View File
@@ -82,7 +82,6 @@ async def test_user(db_session: AsyncSession) -> User:
email="test@example.com", email="test@example.com",
hashed_password=get_password_hash("testpassword123"), hashed_password=get_password_hash("testpassword123"),
is_active=True, is_active=True,
is_verified=True,
) )
db_session.add(user) db_session.add(user)
await db_session.commit() await db_session.commit()
@@ -97,8 +96,7 @@ async def test_admin_user(db_session: AsyncSession) -> User:
email="admin@example.com", email="admin@example.com",
hashed_password=get_password_hash("adminpassword123"), hashed_password=get_password_hash("adminpassword123"),
is_active=True, is_active=True,
is_verified=True, is_superuser=True,
is_admin=True,
) )
db_session.add(user) db_session.add(user)
await db_session.commit() await db_session.commit()
@@ -109,14 +107,14 @@ async def test_admin_user(db_session: AsyncSession) -> User:
@pytest.fixture @pytest.fixture
def auth_headers(test_user: User) -> dict: def auth_headers(test_user: User) -> dict:
"""Generate authentication headers for test user""" """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}"} return {"Authorization": f"Bearer {access_token}"}
@pytest.fixture @pytest.fixture
def admin_auth_headers(test_admin_user: User) -> dict: def admin_auth_headers(test_admin_user: User) -> dict:
"""Generate authentication headers for admin user""" """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}"} return {"Authorization": f"Bearer {access_token}"}
@@ -131,8 +129,7 @@ def user_factory(db_session: AsyncSession):
email: str = None, email: str = None,
password: str = "testpassword123", password: str = "testpassword123",
is_active: bool = True, is_active: bool = True,
is_verified: bool = True, is_superuser: bool = False,
is_admin: bool = False,
) -> User: ) -> User:
if email is None: if email is None:
import uuid import uuid
@@ -143,8 +140,7 @@ def user_factory(db_session: AsyncSession):
email=email, email=email,
hashed_password=get_password_hash(password), hashed_password=get_password_hash(password),
is_active=is_active, is_active=is_active,
is_verified=is_verified, is_superuser=is_superuser,
is_admin=is_admin,
) )
db_session.add(user) db_session.add(user)
await db_session.commit() await db_session.commit()
File diff suppressed because it is too large Load Diff
+1
View File
@@ -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 schemas and validation
- [x] Write unit tests for application factory and core endpoints - [x] Write unit tests for application factory and core endpoints
- [x] Reach 50%+ test coverage (currently 59%) - [x] Reach 50%+ test coverage (currently 59%)
- [x] Write unit tests for admin endpoints (87 tests, 100% coverage on admin.py)
### In Progress 🔨 ### In Progress 🔨
- [ ] Write unit tests for authentication (target 80%+ coverage) - [ ] Write unit tests for authentication (target 80%+ coverage)