Files
shoppy/shop/tests/mixins.py
T
2024-11-22 22:09:10 +01:00

32 lines
713 B
Python

from decimal import Decimal
from django.utils.timezone import now
from shop.models import Product, ProductPrice, Tax
class CreateProductsMixin:
def create_product(
self,
sku="000001",
name="Producto 1",
description="Descripción",
price=Decimal("10.00"),
) -> Product:
tax = Tax.objects.create(
code="IVA",
value=21,
)
product = Product.objects.create(
sku=sku,
name=name,
description=description,
)
ProductPrice.objects.create(
price=price,
product=product,
date=now(),
tax=tax,
)
return product