chore: improve coverage

This commit is contained in:
2024-11-23 00:24:35 +01:00
parent 4247c77a3b
commit a7386454a6
2 changed files with 36 additions and 0 deletions
@@ -92,3 +92,29 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
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")
def test_create_delete_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",
"provider": provider.pk,
},
)
assert response.status_code == status.HTTP_201_CREATED
pk = response.data.get("id")
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.delete(f"/api/v1/shop/product-batches/{pk}/")
assert response.status_code == status.HTTP_204_NO_CONTENT