Files
shoppy/shop/tests/mixins.py
T
2024-11-28 01:07:29 +01:00

33 lines
755 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, created = Tax.objects.get_or_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,
current=True,
)
return product