test: add service tests and fix architecture violations
- Add comprehensive unit tests for FeatureService (24 tests) - Add comprehensive unit tests for UsageService (11 tests) - Fix API-002/API-003 architecture violations in feature/usage APIs - Move database queries from API layer to service layer - Create UsageService for usage and limits management - Create custom exceptions (FeatureNotFoundError, TierNotFoundError) - Fix ValidationException usage in content_pages.py - Refactor vendor features API to use proper response models - All 35 new tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ from pydantic import BaseModel, Field
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import get_current_admin_api, get_db
|
||||
from app.exceptions import ValidationException
|
||||
from app.services.content_page_service import content_page_service
|
||||
from models.database.user import User
|
||||
|
||||
@@ -178,11 +179,9 @@ def create_vendor_page(
|
||||
Vendor pages override platform defaults for a specific vendor.
|
||||
"""
|
||||
if not page_data.vendor_id:
|
||||
from fastapi import HTTPException
|
||||
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="vendor_id is required for vendor pages. Use /platform for platform defaults.",
|
||||
raise ValidationException(
|
||||
message="vendor_id is required for vendor pages. Use /platform for platform defaults.",
|
||||
field="vendor_id",
|
||||
)
|
||||
|
||||
page = content_page_service.create_page(
|
||||
|
||||
Reference in New Issue
Block a user