fooder-api/fooder/test/fixtures/product.py

26 lines
592 B
Python

import pytest
import pytest_asyncio
from fooder.controller.product import ProductController
from fooder.model.product import ProductCreateModel
@pytest.fixture
def product_payload():
return {
"name": "Chicken Breast",
"protein": 31.0,
"carb": 0.0,
"fat": 3.6,
"fiber": 0.0,
}
@pytest_asyncio.fixture
async def product(ctx):
data = ProductCreateModel(name="Chicken Breast", protein=31.0, carb=0.0, fat=3.6, fiber=0.0)
async with ctx.repo.transaction():
ctrl = await ProductController.create(ctx, data)
return ctrl.obj