chore: extracted product batch creation

This commit is contained in:
2024-05-24 20:55:49 +02:00
parent 4501ff8727
commit a6cf0dac93
3 changed files with 25 additions and 3 deletions
+8
View File
@@ -51,6 +51,8 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
pk = response.data.get("id")
response = self.client.get(f"/api/v1/shop/product-batches/{pk}/")
self.product.refresh_from_db()
assert self.product.stock == Decimal("5")
assert response.status_code == status.HTTP_200_OK
def test_create_update_product_batch(self):
@@ -73,6 +75,9 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
response = self.client.get(f"/api/v1/shop/product-batches/{pk}/")
assert response.status_code == status.HTTP_200_OK
self.product.refresh_from_db()
assert self.product.stock == Decimal("5")
response = self.client.patch(
f"/api/v1/shop/product-batches/{pk}/",
{
@@ -81,6 +86,9 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
)
assert response.status_code == status.HTTP_200_OK
self.product.refresh_from_db()
assert self.product.stock == Decimal("10")
response = self.client.get(f"/api/v1/shop/product-batches/{pk}/")
assert response.status_code == status.HTTP_200_OK
assert Decimal(response.data.get("quantity")) == Decimal("10")