Skip to content

Commit fd15f66

Browse files
updated the api test case
1 parent eae7ddd commit fd15f66

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/tests/api/api/test_api_routes.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ def test_fetch_filter_data_basic(create_test_client):
4343
def test_fetch_chart_data_with_filters_basic(create_test_client):
4444
with patch("api.api_routes.ChartService") as MockChartService:
4545
mock_instance = MockChartService.return_value
46-
mock_instance.fetch_chart_data_with_filters = AsyncMock(return_value={"filtered": True})
46+
mock_instance.fetch_chart_data_with_filters = AsyncMock(return_value=[
47+
{
48+
"id": "TOTAL_CALLS",
49+
"chart_name": "Total Calls",
50+
"chart_type": "card",
51+
"chart_value": [
52+
{"name": "Total Calls", "value": float("nan"), "unit_of_measurement": ""}
53+
]
54+
}
55+
])
4756

4857
client = create_test_client()
4958
payload = {
@@ -54,9 +63,18 @@ def test_fetch_chart_data_with_filters_basic(create_test_client):
5463
}
5564
}
5665
response = client.post("/fetchChartDataWithFilters", json=payload)
57-
66+
expected = [
67+
{
68+
"id": "TOTAL_CALLS",
69+
"chart_name": "Total Calls",
70+
"chart_type": "card",
71+
"chart_value": [
72+
{"name": "Total Calls", "value": None, "unit_of_measurement": ""}
73+
]
74+
}
75+
]
5876
assert response.status_code == 200
59-
assert response.json() == {"filtered": True}
77+
assert response.json() == expected
6078

6179
def test_fetch_chart_data_with_filters_error(create_test_client):
6280
with patch("api.api_routes.ChartService") as MockChartService:

0 commit comments

Comments
 (0)