From e09bef3c355e69cdb0890e8f6c50e1e405d0bde2 Mon Sep 17 00:00:00 2001 From: Arafat Olayiwola Date: Thu, 4 Jul 2024 16:59:50 +0100 Subject: [PATCH] add report sales for period day --- test/test_product.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test_product.py b/test/test_product.py index 7840045..3b97796 100644 --- a/test/test_product.py +++ b/test/test_product.py @@ -121,6 +121,27 @@ def test_low_stock_report(api_client, admin_user, product_data, get_token): assert response.status_code == status.HTTP_200_OK assert response.data[0]['quantity'] < 10 # Assuming low stock threshold is less than 10 + + +@pytest.mark.django_db +def test_sales_report(api_client, admin_user, product_data, get_token): + # Assume some sales have occurred in the specified period + period = 'day' # Example sales period + + # Perform authentication + token = get_token(admin_user, 'admin123') + api_client.credentials(HTTP_AUTHORIZATION='Bearer ' + token) + + # Request the sales report for the specified period + response = api_client.get(f'/api/inventory/report/sales/{period}/') + assert response.status_code == status.HTTP_200_OK + + assert 'total_sales' not in response.data + assert len(response.data) <= 0 + def test_unauthenticated_user_cannot_access_low_stock_report(api_client): response = api_client.get('/api/inventory/report/stock/') - assert response.status_code == status.HTTP_401_UNAUTHORIZED \ No newline at end of file + assert response.status_code == status.HTTP_401_UNAUTHORIZED + + +