69 lines
1.6 KiB
Python
69 lines
1.6 KiB
Python
from src import models
|
|
|
|
from .productors import productor_factory
|
|
|
|
|
|
def product_body_factory(**kwargs):
|
|
data = dict(
|
|
name='product test 1',
|
|
unit=models.Unit.PIECE,
|
|
price=10.2,
|
|
price_kg=20.4,
|
|
quantity=500,
|
|
quantity_unit='g',
|
|
type=models.ProductType.OCCASIONAL,
|
|
productor_id=1,
|
|
)
|
|
data.update(kwargs)
|
|
return data
|
|
|
|
|
|
def product_create_factory(**kwargs):
|
|
data = dict(
|
|
name='product test 1',
|
|
unit=models.Unit.PIECE,
|
|
price=10.2,
|
|
price_kg=20.4,
|
|
quantity=500,
|
|
quantity_unit='g',
|
|
type=models.ProductType.OCCASIONAL,
|
|
productor_id=1,
|
|
)
|
|
data.update(kwargs)
|
|
return models.ProductCreate(**data)
|
|
|
|
|
|
def product_update_factory(**kwargs):
|
|
data = dict(
|
|
name='product test 1',
|
|
unit=models.Unit.PIECE,
|
|
price=10.2,
|
|
price_kg=20.4,
|
|
quantity=500,
|
|
quantity_unit='g',
|
|
type=models.ProductType.OCCASIONAL,
|
|
productor_id=1,
|
|
)
|
|
data.update(kwargs)
|
|
return models.ProductUpdate(**data)
|
|
|
|
|
|
def product_public_factory(productor=None, shipments=[], **kwargs):
|
|
if productor is None:
|
|
productor = productor_factory()
|
|
data = dict(
|
|
id=1,
|
|
name='product test 1',
|
|
unit=models.Unit.PIECE,
|
|
price=10.2,
|
|
price_kg=20.4,
|
|
quantity=500,
|
|
quantity_unit='g',
|
|
type=models.ProductType.OCCASIONAL,
|
|
productor_id=1,
|
|
productor=productor,
|
|
shipments=shipments,
|
|
)
|
|
data.update(kwargs)
|
|
return models.ProductPublic(**data)
|