chore: improve coverage
This commit is contained in:
+10
@@ -5,3 +5,13 @@ exclude_lines =
|
|||||||
|
|
||||||
# Don't complain if tests don't hit defensive assertion code:
|
# Don't complain if tests don't hit defensive assertion code:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
[run]
|
||||||
|
omit =
|
||||||
|
# omit anything in a .local directory anywhere
|
||||||
|
*/.idea/*
|
||||||
|
*/src/*
|
||||||
|
*/**/admin.py
|
||||||
|
*/**/asgi.py
|
||||||
|
*/**/wsgi.py
|
||||||
|
*/**/celery.py
|
||||||
|
|||||||
@@ -92,3 +92,29 @@ class TestProductBatchesAPI(APITestCase, TestUserAuthenticationMixin):
|
|||||||
response = self.client.get(f"/api/v1/shop/product-batches/{pk}/")
|
response = self.client.get(f"/api/v1/shop/product-batches/{pk}/")
|
||||||
assert response.status_code == status.HTTP_200_OK
|
assert response.status_code == status.HTTP_200_OK
|
||||||
assert Decimal(response.data.get("quantity")) == Decimal("10")
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user