Application fully migrated to modular approach
This commit is contained in:
@@ -31,7 +31,7 @@ def create_product(product: ProductCreate, db: Session = Depends(get_db)):
|
||||
raise HTTPException(status_code=400, detail="Invalid GTIN")
|
||||
|
||||
# Business logic
|
||||
db_product = Product(**product.dict())
|
||||
db_product = Product(**product.model_dump())
|
||||
db.add(db_product)
|
||||
db.commit()
|
||||
|
||||
@@ -276,14 +276,14 @@ class TestProductService:
|
||||
# test_products_api.py
|
||||
def test_create_product_endpoint(self, client, auth_headers):
|
||||
product_data = {"product_id": "TEST001", "title": "Test Product"}
|
||||
response = client.post("/api/v1/products", headers=auth_headers, json=product_data)
|
||||
response = client.post("/api/v1/product", headers=auth_headers, json=product_data)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["product_id"] == "TEST001"
|
||||
|
||||
def test_create_product_validation_error(self, client, auth_headers):
|
||||
product_data = {"product_id": "TEST001", "gtin": "invalid"}
|
||||
response = client.post("/api/v1/products", headers=auth_headers, json=product_data)
|
||||
response = client.post("/api/v1/product", headers=auth_headers, json=product_data)
|
||||
|
||||
assert response.status_code == 400
|
||||
assert "Invalid GTIN format" in response.json()["detail"]
|
||||
@@ -472,7 +472,7 @@ def create_product(product: ProductCreate, db: Session = Depends(get_db)):
|
||||
product.gtin = normalized_gtin
|
||||
|
||||
# Create product
|
||||
db_product = Product(**product.dict())
|
||||
db_product = Product(**product.model_dump())
|
||||
db.add(db_product)
|
||||
db.commit()
|
||||
db.refresh(db_product)
|
||||
@@ -497,7 +497,7 @@ class ProductService:
|
||||
product_data.gtin = normalized_gtin
|
||||
|
||||
# Create product
|
||||
db_product = Product(**product_data.dict())
|
||||
db_product = Product(**product_data.model_dump())
|
||||
db.add(db_product)
|
||||
db.commit()
|
||||
db.refresh(db_product)
|
||||
|
||||
Reference in New Issue
Block a user