Skip to content

Commit

Permalink
fixed the correct file for linting and edited the extended testing again
Browse files Browse the repository at this point in the history
  • Loading branch information
DaleMG committed Oct 15, 2024
1 parent ff2e6cc commit 0d52074
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion libs/community/extended_testing_deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ arxiv>=1.4,<2
assemblyai>=0.17.0,<0.18
atlassian-python-api>=3.36.0,<4
azure-ai-documentintelligence>=1.0.0b1,<2
azure-ai-translation-text>=1.0.0b1
azure.ai.translation.text>=1.0.0b1
azure-identity>=1.15.0,<2
azure-search-documents==11.4.0
beautifulsoup4>=4,<5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from typing import Any

import pytest

from langchain_community.tools.azure_ai_services.azure_file_translation import (
AzureFileTranslateTool
AzureFileTranslateTool,
)

_THIS_DIR = Path(__file__).parents[3]
Expand All @@ -17,8 +18,10 @@ def test_tool_initialization(mocker: Any) -> None:
mocker.patch("azure.core.credentials.AzureKeyCredential", autospec=True)

mock_translate_client = mocker.Mock()
mocker.patch("azure.ai.translation.text.TextTranslationClient",
return_value=mock_translate_client)
mocker.patch(
"azure.ai.translation.text.TextTranslationClient",
return_value=mock_translate_client,
)

key = "key"
endpoint = "endpoint"
Expand All @@ -28,7 +31,7 @@ def test_tool_initialization(mocker: Any) -> None:
text_translation_key=key,
text_translation_endpoint=endpoint,
region=region,
translate_client=mock_translate_client
translate_client=mock_translate_client,
)

assert tool.text_translation_key == key
Expand All @@ -43,26 +46,25 @@ def test_translation_with_file(mocker: Any) -> None:
endpoint = "endpoint"
region = "westus2"

mocker.patch("azure.core.credentials.AzureKeyCredential",
autospec=True)
mocker.patch("azure.core.credentials.AzureKeyCredential", autospec=True)

mock_translate_client = mocker.Mock()
mocker.patch("azure.ai.translation.text.TextTranslationClient",
return_value=mock_translate_client)
mocker.patch(
"azure.ai.translation.text.TextTranslationClient",
return_value=mock_translate_client,
)

tool = AzureFileTranslateTool(
text_translation_key=key,
text_translation_endpoint=endpoint,
region=region,
translate_client=mock_translate_client
translate_client=mock_translate_client,
)

mock_translate_client.translate.return_value = [
{
'detectedLanguage': {'language': 'en', 'score': 1.0},
'translations': [
{'text': 'Hola, mi nombre es Azure', 'to': 'es'}
]
"detectedLanguage": {"language": "en", "score": 1.0},
"translations": [{"text": "Hola, mi nombre es Azure", "to": "es"}],
}
]

Expand All @@ -80,18 +82,19 @@ def test_translation_with_no_file(mocker: Any) -> None:
endpoint = "endpoint"
region = "westus2"

mocker.patch("azure.core.credentials.AzureKeyCredential",
autospec=True)
mocker.patch("azure.core.credentials.AzureKeyCredential", autospec=True)

mock_translate_client = mocker.Mock()
mocker.patch("azure.ai.translation.text.TextTranslationClient",
return_value=mock_translate_client)
mocker.patch(
"azure.ai.translation.text.TextTranslationClient",
return_value=mock_translate_client,
)

tool = AzureFileTranslateTool(
text_translation_key=key,
text_translation_endpoint=endpoint,
region=region,
translate_client=mock_translate_client
translate_client=mock_translate_client,
)

file_input: str = ""
Expand Down

0 comments on commit 0d52074

Please sign in to comment.