test updates to take into account exception management
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
import re
|
||||
# product.py - Simplified validation
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, EmailStr, Field, field_validator
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from models.schemas.stock import StockSummaryResponse
|
||||
|
||||
|
||||
class ProductBase(BaseModel):
|
||||
product_id: Optional[str] = None
|
||||
title: Optional[str] = None
|
||||
@@ -45,42 +42,30 @@ class ProductBase(BaseModel):
|
||||
identifier_exists: Optional[str] = None
|
||||
shipping: Optional[str] = None
|
||||
currency: Optional[str] = None
|
||||
# New marketplace fields
|
||||
marketplace: Optional[str] = None
|
||||
shop_name: Optional[str] = None
|
||||
|
||||
|
||||
class ProductCreate(ProductBase):
|
||||
product_id: str = Field(..., min_length=1, description="Product ID is required")
|
||||
title: str = Field(..., min_length=1, description="Title is required")
|
||||
|
||||
@field_validator("product_id", "title")
|
||||
@classmethod
|
||||
def validate_required_fields(cls, v):
|
||||
if not v or not v.strip():
|
||||
raise ValueError("Field cannot be empty")
|
||||
return v.strip()
|
||||
|
||||
product_id: str = Field(..., description="Product identifier")
|
||||
title: str = Field(..., description="Product title")
|
||||
# Removed: min_length constraints and custom validators
|
||||
# Service will handle empty string validation with proper domain exceptions
|
||||
|
||||
class ProductUpdate(ProductBase):
|
||||
pass
|
||||
|
||||
|
||||
class ProductResponse(ProductBase):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
|
||||
class ProductListResponse(BaseModel):
|
||||
products: List[ProductResponse]
|
||||
total: int
|
||||
skip: int
|
||||
limit: int
|
||||
|
||||
|
||||
class ProductDetailResponse(BaseModel):
|
||||
product: ProductResponse
|
||||
stock_info: Optional[StockSummaryResponse] = None
|
||||
|
||||
Reference in New Issue
Block a user