feat: added sku and resetted migrations

This commit is contained in:
2024-05-21 19:36:28 +02:00
parent ff1a7e2c68
commit ea9830a976
15 changed files with 355 additions and 572 deletions
+10
View File
@@ -1,3 +1,5 @@
import random
import string
from decimal import Decimal
from rest_framework import status
@@ -19,8 +21,12 @@ class TestProductsAPI(APITestCase, TestUserAuthenticationMixin):
)
self.tag = Tag.objects.create(name="Alimentos")
def get_random_sku(self):
return ''.join(random.choices(string.ascii_uppercase, k=16))
def create_products(self):
self.product = Product.objects.create(
sku=self.get_random_sku(),
name="Papafritas",
description="Las mejores papafritas",
is_digital_asset=False,
@@ -52,6 +58,7 @@ class TestProductsAPI(APITestCase, TestUserAuthenticationMixin):
response = self.client.post(
"/api/v1/shop/products/",
{
"sku": self.get_random_sku(),
"name": "Papafritas",
"description": "Las mejores papafritas",
"is_digital_asset": False,
@@ -73,6 +80,7 @@ class TestProductsAPI(APITestCase, TestUserAuthenticationMixin):
response = self.client.post(
"/api/v1/shop/products/",
{
"sku": self.get_random_sku(),
"name": "Papafritas",
"description": "Las mejores papafritas",
"is_digital_asset": False,
@@ -103,6 +111,7 @@ class TestProductsAPI(APITestCase, TestUserAuthenticationMixin):
response = self.client.post(
"/api/v1/shop/products/",
{
"sku": self.get_random_sku(),
"name": "Papafritas",
"description": "Las mejores papafritas",
"is_digital_asset": False,
@@ -142,6 +151,7 @@ class TestProductsAPI(APITestCase, TestUserAuthenticationMixin):
response = self.client.post(
"/api/v1/shop/products/",
{
"sku": self.get_random_sku(),
"name": "Papafritas",
"description": "Las mejores papafritas",
"is_digital_asset": False,
+3
View File
@@ -14,14 +14,17 @@ class ShopModelsTest(TestCase):
def create_products(self):
self.potatoes = Product.objects.create(
sku='0000001',
name="Patatas",
stock=Decimal("100.00"),
)
self.gasoline = Product.objects.create(
sku='0000002',
name="Gasolina",
stock=Decimal("800.00"),
)
self.usb_c = Product.objects.create(
sku='0000003',
name="Cable USB-C",
stock=Decimal("5.00"),
)