Skip to content

Commit 61d9abd

Browse files
unittestcase
1 parent d2cb4fe commit 61d9abd

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

documents/CustomizingAzdParameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ By default this template will use the environment name as the prefix to prevent
1414
| `AZURE_CONTENT_UNDERSTANDING_LOCATION` | string | `swedencentral` | Specifies the region for content understanding resources. |
1515
| `AZURE_SECONDARY_LOCATION` | string | `eastus2` | Specifies a secondary Azure region. |
1616
| `AZURE_OPENAI_MODEL_DEPLOYMENT_TYPE` | string | `GlobalStandard` | Defines the model deployment type (allowed: `Standard`, `GlobalStandard`). |
17-
| `AZURE_OPEN_AI_DEPLOYMENT_MODEL` | string | `gpt-4o-mini` | Specifies the GPT model name (e.g., `gpt-4`, `gpt-4o-mini`). |
17+
| `AZURE_OPENAI_DEPLOYMENT_MODEL` | string | `gpt-4o-mini` | Specifies the GPT model name (e.g., `gpt-4`, `gpt-4o-mini`). |
1818
| `AZURE_ENV_MODEL_VERSION` | string | `2024-07-18` | Sets the Azure model version (allowed: `2024-08-06`, etc.). |
1919
| `AZURE_OPENAI_API_VERSION` | string | `2025-01-01-preview` | Specifies the API version for Azure OpenAI. |
2020
| `AZURE_OPENAI_DEPLOYMENT_MODEL_CAPACITY` | integer | `30` | Sets the GPT model capacity. |

src/api/.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ DISPLAY_CHART_DEFAULT="False"
1818
REACT_APP_LAYOUT_CONFIG="{\n \"appConfig\": {\n \"THREE_COLUMN\": {\n \"DASHBOARD\": 50,\n \"CHAT\": 33,\n \"CHATHISTORY\": 17\n },\n \"TWO_COLUMN\": {\n \"DASHBOARD_CHAT\": {\n \"DASHBOARD\": 65,\n \"CHAT\": 35\n },\n \"CHAT_CHATHISTORY\": {\n \"CHAT\": 80,\n \"CHATHISTORY\": 20\n }\n }\n },\n \"charts\": [\n {\n \"id\": \"SATISFIED\",\n \"name\": \"Satisfied\",\n \"type\": \"card\",\n \"layout\": { \"row\": 1, \"column\": 1, \"height\": 11 }\n },\n {\n \"id\": \"TOTAL_CALLS\",\n \"name\": \"Total Calls\",\n \"type\": \"card\",\n \"layout\": { \"row\": 1, \"column\": 2, \"span\": 1 }\n },\n {\n \"id\": \"AVG_HANDLING_TIME\",\n \"name\": \"Average Handling Time\",\n \"type\": \"card\",\n \"layout\": { \"row\": 1, \"column\": 3, \"span\": 1 }\n },\n {\n \"id\": \"SENTIMENT\",\n \"name\": \"Topics Overview\",\n \"type\": \"donutchart\",\n \"layout\": { \"row\": 2, \"column\": 1, \"width\": 40, \"height\": 44.5 }\n },\n {\n \"id\": \"AVG_HANDLING_TIME_BY_TOPIC\",\n \"name\": \"Average Handling Time By Topic\",\n \"type\": \"bar\",\n \"layout\": { \"row\": 2, \"column\": 2, \"row-span\": 2, \"width\": 60 }\n },\n {\n \"id\": \"TOPICS\",\n \"name\": \"Trending Topics\",\n \"type\": \"table\",\n \"layout\": { \"row\": 3, \"column\": 1, \"span\": 2 }\n },\n {\n \"id\": \"KEY_PHRASES\",\n \"name\": \"Key Phrases\",\n \"type\": \"wordcloud\",\n \"layout\": { \"row\": 3, \"column\": 2, \"height\": 44.5 }\n }\n ]\n}"
1919
SQLDB_DATABASE=
2020
SQLDB_SERVER=
21+
SQLDB_USER_MID=
22+
SQLDB_USERNAME=
2123
USE_AI_PROJECT_CLIENT="False"
2224
USE_CHAT_HISTORY_ENABLED="True"

src/api/common/config/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"""
77

88
import os
9+
from dotenv import load_dotenv
10+
load_dotenv()
911

1012

1113
class Config:
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from unittest.mock import patch, MagicMock
2+
import pytest
3+
import sys
4+
import os
5+
6+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../api")))
7+
8+
import helpers.azure_openai_helper as azure_openai_helper
9+
10+
class TestAzureOpenAIHelper:
11+
@patch("helpers.azure_openai_helper.openai.AzureOpenAI")
12+
@patch("helpers.azure_openai_helper.get_bearer_token_provider")
13+
@patch("helpers.azure_openai_helper.DefaultAzureCredential")
14+
@patch("helpers.azure_openai_helper.Config")
15+
def test_get_azure_openai_client(
16+
self, mock_config, mock_credential, mock_token_provider, mock_azure_openai
17+
):
18+
"""Test that get_azure_openai_client returns a properly configured client."""
19+
# Arrange
20+
mock_config_instance = MagicMock()
21+
mock_config_instance.azure_openai_endpoint = "https://test-endpoint"
22+
mock_config_instance.azure_openai_api_version = "2024-01-01"
23+
mock_config.return_value = mock_config_instance
24+
25+
mock_token = MagicMock()
26+
mock_token_provider.return_value = mock_token
27+
28+
mock_client = MagicMock()
29+
mock_azure_openai.return_value = mock_client
30+
31+
# Act
32+
client = azure_openai_helper.get_azure_openai_client()
33+
34+
# Assert
35+
mock_config.assert_called_once()
36+
mock_credential.assert_called_once()
37+
mock_token_provider.assert_called_once_with(
38+
mock_credential.return_value, "https://cognitiveservices.azure.com/.default"
39+
)
40+
mock_azure_openai.assert_called_once_with(
41+
azure_endpoint="https://test-endpoint",
42+
api_version="2024-01-01",
43+
azure_ad_token_provider=mock_token,
44+
)
45+
assert client == mock_client

0 commit comments

Comments
 (0)