feat: added provider to product batch

This commit is contained in:
Pablo Moreno
2024-05-14 17:59:56 +02:00
parent efae21ee82
commit 3c25c115ca
5 changed files with 63 additions and 6 deletions
+30 -4
View File
@@ -4,7 +4,7 @@ from rest_framework import status
from rest_framework.test import APITestCase
from config.tests.mixins import TestUserAuthenticationMixin
from shop.models import Product
from shop.models import Product, Provider
class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
@@ -13,6 +13,19 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
def setUp(self):
self.create_user()
def create_provider(self):
return Provider.objects.create(
vat_id="11111111H",
name="Mandalorians",
email="din@djarin.com",
phone="612345678",
address="Mandalore",
city="Mandalore",
state="Mandalore",
country="Mandalore",
zip="12345",
)
def create_product(self):
self.product = Product.objects.create(
name="Papafritas",
@@ -24,9 +37,15 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
def test_create_retrieve_product_batch(self):
self.login()
self.create_product()
provider = self.create_provider()
response = self.client.post(
"/api/v1/shop/product-batches/",
{"code": "B00001", "product": self.product.pk, "quantity": "5"},
{
"code": "B00001",
"product": self.product.pk,
"quantity": "5",
"provider": provider.pk,
},
)
assert response.status_code == status.HTTP_201_CREATED
pk = response.data.get("id")
@@ -34,12 +53,19 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
response = self.client.get(f"/api/v1/shop/product-batches/{pk}/")
assert response.status_code == status.HTTP_200_OK
def test_create_update_tax(self):
def test_create_update_product_batch(self):
self.login()
self.create_product()
provider = self.create_provider()
response = self.client.post(
"/api/v1/shop/product-batches/",
{"code": "B00001", "product": self.product.pk, "quantity": "5"},
{
"code": "B00001",
"product": self.product.pk,
"quantity": "5",
"provider": provider.pk,
},
)
assert response.status_code == status.HTTP_201_CREATED
pk = response.data.get("id")