Coverage for backend \ app \ Productos \ schemas \ productoSchemas.py: 100.00%

46 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-29 16:13 -0500

1from pydantic import BaseModel, Field 

2from typing import Optional, List 

3from app.Productos.schemas.categoriaProductoSchemas import CategoriaProductoRespuestaSchema 

4from app.Productos.schemas.proveedorSchemas import ProveedorRespuestaSchema 

5 

6class ProductoBaseSchema(BaseModel): 

7 idCategoriaProducto: int = Field(..., example=1) 

8 idProveedor: int = Field(..., example=1) 

9 nombreProducto: str = Field(..., min_length=1, max_length=100, example="Cola 2 Litros") 

10 descripcionProducto: Optional[str] = Field(None, max_length=255, example="Bebida gaseosa sabor cola") 

11 precioUnitarioVenta: float = Field(..., gt=0, example=2.50) 

12 precioUnitarioCompra: float = Field(..., gt=0, example=1.80) 

13 tieneIva: bool = Field(..., example=True) 

14 

15class ProductoCrearSchema(ProductoBaseSchema): 

16 cantidadDisponible: Optional[int] = Field(None, example=0, ge=0) 

17 cantidadMinima: Optional[int] = Field(None, example=0, ge=0) 

18 

19class ProductoActualizarSchema(BaseModel): 

20 idCategoriaProducto: Optional[int] = Field(None, example=1) 

21 idProveedor: Optional[int] = Field(None, example=1) 

22 nombreProducto: Optional[str] = Field(None, min_length=1, max_length=100, example="Cola 2 Litros") 

23 descripcionProducto: Optional[str] = Field(None, max_length=255, example="Bebida gaseosa sabor cola") 

24 precioUnitarioVenta: Optional[float] = Field(None, gt=0, example=2.50) 

25 precioUnitarioCompra: Optional[float] = Field(None, gt=0, example=1.80) 

26 tieneIva: Optional[bool] = None 

27 activoProducto: Optional[bool] = None 

28 

29class ProductoRespuestaSchema(BaseModel): 

30 idProducto: int 

31 idCategoriaProducto: int 

32 idProveedor: int 

33 nombreProducto: str 

34 descripcionProducto: Optional[str] = None 

35 precioUnitarioVenta: float 

36 precioUnitarioCompra: float 

37 tieneIva: bool 

38 activoProducto: bool 

39 categoria: CategoriaProductoRespuestaSchema 

40 proveedor: ProveedorRespuestaSchema 

41 

42 class Config: 

43 from_attributes = True 

44 

45 

46class ProductoResumenSchema(BaseModel): 

47 idProducto: int 

48 nombreProducto: str 

49 precioUnitarioVenta: float 

50 tieneIva: bool 

51 activoProducto: bool 

52 

53 class Config: 

54 from_attributes = True