Skip to content

Commit 8a0b811

Browse files
fix testcase issues
1 parent de8470e commit 8a0b811

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/tests/api/plugins/test_chat_with_data_plugin.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TestChatWithDataPlugin:
2929
@pytest.mark.asyncio
3030
@patch("plugins.chat_with_data_plugin.execute_sql_query", new_callable=AsyncMock)
3131
@patch("plugins.chat_with_data_plugin.SQLAgentFactory.get_agent", new_callable=AsyncMock)
32-
async def test_get_sql_response_with_sql_agent(self, mock_get_agent, mock_execute_sql, chat_plugin):
32+
async def test_get_database_metrics_with_sql_agent(self, mock_get_agent, mock_execute_sql, chat_plugin):
3333
# Mocks
3434
mock_agent = MagicMock()
3535
mock_agent.id = "agent-id"
@@ -63,7 +63,7 @@ async def test_get_sql_response_with_sql_agent(self, mock_get_agent, mock_execut
6363
mock_client.agents.threads.delete.return_value = None
6464

6565
# Act
66-
result = await chat_plugin.get_sql_response("Total number of calls by date for last 7 days")
66+
result = await chat_plugin.get_database_metrics("Total number of calls by date for last 7 days")
6767

6868
# Assert
6969
assert result == "(datetime.date(2025, 6, 27), 11)(datetime.date(2025, 6, 28), 20)(datetime.date(2025, 6, 29), 29)(datetime.date(2025, 6, 30), 17)(datetime.date(2025, 7, 1), 19)(datetime.date(2025, 7, 2), 16)"
@@ -77,12 +77,12 @@ async def test_get_sql_response_with_sql_agent(self, mock_get_agent, mock_execut
7777
@pytest.mark.asyncio
7878
@patch("plugins.chat_with_data_plugin.execute_sql_query")
7979
@patch("plugins.chat_with_data_plugin.SQLAgentFactory.get_agent", new_callable=AsyncMock)
80-
async def test_get_sql_response_exception(self, mock_get_agent, mock_execute_sql, chat_plugin):
80+
async def test_get_database_metrics_exception(self, mock_get_agent, mock_execute_sql, chat_plugin):
8181
# Setup mock to raise exception
8282
mock_get_agent.side_effect = Exception("Test error")
8383

8484
# Call the method
85-
result = await chat_plugin.get_sql_response("Show me data")
85+
result = await chat_plugin.get_database_metrics("Show me data")
8686

8787
# Assertions
8888
assert result == "Details could not be retrieved. Please try again later."
@@ -91,7 +91,7 @@ async def test_get_sql_response_exception(self, mock_get_agent, mock_execute_sql
9191

9292
@pytest.mark.asyncio
9393
@patch("plugins.chat_with_data_plugin.SearchAgentFactory.get_agent", new_callable=AsyncMock)
94-
async def test_get_answers_from_calltranscripts_success(self, mock_get_agent, chat_plugin):
94+
async def test_get_call_insights_success(self, mock_get_agent, chat_plugin):
9595
# Use the fixture passed by pytest
9696
self.chat_plugin = chat_plugin # or just use `chat_plugin` directly
9797

@@ -138,7 +138,7 @@ async def test_get_answers_from_calltranscripts_success(self, mock_get_agent, ch
138138
mock_client.agents.threads.delete.return_value = None
139139

140140
# Call the method
141-
result = await chat_plugin.get_answers_from_calltranscripts("What is the summary?")
141+
result = await chat_plugin.get_call_insights("What is the summary?")
142142

143143
# Assert
144144
assert isinstance(result, dict)
@@ -147,19 +147,19 @@ async def test_get_answers_from_calltranscripts_success(self, mock_get_agent, ch
147147

148148
@pytest.mark.asyncio
149149
@patch("plugins.chat_with_data_plugin.SearchAgentFactory.get_agent", new_callable=AsyncMock)
150-
async def test_get_answers_from_calltranscripts_exception(self, mock_get_agent, chat_plugin):
150+
async def test_get_call_insights_exception(self, mock_get_agent, chat_plugin):
151151
# Setup the mock to raise an exception
152152
mock_get_agent.side_effect = Exception("Test error")
153153

154154
# Call the method
155-
result = await chat_plugin.get_answers_from_calltranscripts("Sample question")
155+
result = await chat_plugin.get_call_insights("Sample question")
156156

157157
# Assertions
158158
assert result == "Details could not be retrieved. Please try again later."
159159

160160
@pytest.mark.asyncio
161161
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
162-
async def test_get_chart_data_success(self, mock_get_agent, chat_plugin):
162+
async def test_generate_chart_data_success(self, mock_get_agent, chat_plugin):
163163
# Mock agent and client setup
164164
mock_agent = MagicMock()
165165
mock_agent.id = "chart-agent-id"
@@ -187,7 +187,7 @@ async def test_get_chart_data_success(self, mock_get_agent, chat_plugin):
187187
mock_client.agents.threads.delete.return_value = None
188188

189189
# Call the method with combined input
190-
result = await chat_plugin.get_chart_data(
190+
result = await chat_plugin.generate_chart_data(
191191
"Create a bar chart. Total calls by date: 2025-06-27: 11, 2025-06-28: 20"
192192
)
193193

@@ -208,7 +208,7 @@ async def test_get_chart_data_success(self, mock_get_agent, chat_plugin):
208208

209209
@pytest.mark.asyncio
210210
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
211-
async def test_get_chart_data_failed_run(self, mock_get_agent, chat_plugin):
211+
async def test_generate_chart_data_failed_run(self, mock_get_agent, chat_plugin):
212212
# Mock agent and client setup
213213
mock_agent = MagicMock()
214214
mock_agent.id = "chart-agent-id"
@@ -227,7 +227,7 @@ async def test_get_chart_data_failed_run(self, mock_get_agent, chat_plugin):
227227
mock_client.agents.runs.create_and_process.return_value = mock_run
228228

229229
# Call the method with single input parameter
230-
result = await chat_plugin.get_chart_data("Create a chart with some data")
230+
result = await chat_plugin.generate_chart_data("Create a chart with some data")
231231

232232
# Assert
233233
assert result == "Details could not be retrieved. Please try again later."
@@ -240,19 +240,19 @@ async def test_get_chart_data_failed_run(self, mock_get_agent, chat_plugin):
240240

241241
@pytest.mark.asyncio
242242
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
243-
async def test_get_chart_data_exception(self, mock_get_agent, chat_plugin):
243+
async def test_generate_chart_data_exception(self, mock_get_agent, chat_plugin):
244244
# Setup mock to raise exception
245245
mock_get_agent.side_effect = Exception("Chart agent error")
246246

247247
# Call the method with single input parameter
248-
result = await chat_plugin.get_chart_data("Create a chart with some data")
248+
result = await chat_plugin.generate_chart_data("Create a chart with some data")
249249

250250
# Assert
251251
assert result == "Details could not be retrieved. Please try again later."
252252

253253
@pytest.mark.asyncio
254254
@patch("plugins.chat_with_data_plugin.ChartAgentFactory.get_agent", new_callable=AsyncMock)
255-
async def test_get_chart_data_empty_response(self, mock_get_agent, chat_plugin):
255+
async def test_generate_chart_data_empty_response(self, mock_get_agent, chat_plugin):
256256
# Mock agent and client setup
257257
mock_agent = MagicMock()
258258
mock_agent.id = "chart-agent-id"
@@ -276,7 +276,7 @@ async def test_get_chart_data_empty_response(self, mock_get_agent, chat_plugin):
276276
mock_client.agents.threads.delete.return_value = None
277277

278278
# Call the method with single input parameter
279-
result = await chat_plugin.get_chart_data("Create a chart with some data")
279+
result = await chat_plugin.generate_chart_data("Create a chart with some data")
280280

281281
# Assert - should return empty string when no agent messages found
282282
assert result == ""

0 commit comments

Comments
 (0)