Nidhal Baccouri
commited on
Commit
·
81548de
1
Parent(s):
9bef22f
fixed poetry install
Browse files
.github/workflows/production-tests.yml
CHANGED
|
@@ -23,7 +23,8 @@ jobs:
|
|
| 23 |
- name: Install poetry
|
| 24 |
run: |
|
| 25 |
which python
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
- name: Install dependencies
|
| 29 |
run: |
|
|
|
|
| 23 |
- name: Install poetry
|
| 24 |
run: |
|
| 25 |
which python
|
| 26 |
+
which pipx
|
| 27 |
+
pipx install poetry
|
| 28 |
|
| 29 |
- name: Install dependencies
|
| 30 |
run: |
|
.github/workflows/release.yml
CHANGED
|
@@ -29,7 +29,8 @@ jobs:
|
|
| 29 |
- name: Install poetry
|
| 30 |
run: |
|
| 31 |
which python
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
- name: View poetry version
|
| 35 |
run: poetry --version
|
|
|
|
| 29 |
- name: Install poetry
|
| 30 |
run: |
|
| 31 |
which python
|
| 32 |
+
which pipx
|
| 33 |
+
pipx install poetry
|
| 34 |
|
| 35 |
- name: View poetry version
|
| 36 |
run: poetry --version
|
.github/workflows/test-release.yml
CHANGED
|
@@ -21,7 +21,8 @@ jobs:
|
|
| 21 |
- name: Install poetry
|
| 22 |
run: |
|
| 23 |
which python
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
- name: View poetry version
|
| 27 |
run: poetry --version
|
|
|
|
| 21 |
- name: Install poetry
|
| 22 |
run: |
|
| 23 |
which python
|
| 24 |
+
which pipx
|
| 25 |
+
pipx install poetry
|
| 26 |
|
| 27 |
- name: View poetry version
|
| 28 |
run: poetry --version
|
.github/workflows/test.yml
CHANGED
|
@@ -6,7 +6,7 @@ jobs:
|
|
| 6 |
test:
|
| 7 |
strategy:
|
| 8 |
matrix:
|
| 9 |
-
python-version: ["3.7"]
|
| 10 |
os: [ubuntu-latest] # we can add other os like macOS-latest
|
| 11 |
runs-on: ${{ matrix.os }}
|
| 12 |
steps:
|
|
|
|
| 6 |
test:
|
| 7 |
strategy:
|
| 8 |
matrix:
|
| 9 |
+
python-version: [ "3.7", "3.8", "3.9" ]
|
| 10 |
os: [ubuntu-latest] # we can add other os like macOS-latest
|
| 11 |
runs-on: ${{ matrix.os }}
|
| 12 |
steps:
|
deep_translator/microsoft.py
CHANGED
|
@@ -11,7 +11,11 @@ import requests
|
|
| 11 |
|
| 12 |
from deep_translator.base import BaseTranslator
|
| 13 |
from deep_translator.constants import BASE_URLS, MSFT_ENV_VAR
|
| 14 |
-
from deep_translator.exceptions import
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
from deep_translator.validate import is_input_valid
|
| 16 |
|
| 17 |
|
|
@@ -100,6 +104,9 @@ class MicrosoftTranslator(BaseTranslator):
|
|
| 100 |
exc_type, value, traceback = sys.exc_info()
|
| 101 |
logging.warning(f"Returned error: {exc_type.__name__}")
|
| 102 |
|
|
|
|
|
|
|
|
|
|
| 103 |
# Where Microsoft API responds with an api error, it returns a dict in response.json()
|
| 104 |
if type(response.json()) is dict:
|
| 105 |
error_message = response.json()["error"]
|
|
|
|
| 11 |
|
| 12 |
from deep_translator.base import BaseTranslator
|
| 13 |
from deep_translator.constants import BASE_URLS, MSFT_ENV_VAR
|
| 14 |
+
from deep_translator.exceptions import (
|
| 15 |
+
ApiKeyException,
|
| 16 |
+
MicrosoftAPIerror,
|
| 17 |
+
TranslationNotFound,
|
| 18 |
+
)
|
| 19 |
from deep_translator.validate import is_input_valid
|
| 20 |
|
| 21 |
|
|
|
|
| 104 |
exc_type, value, traceback = sys.exc_info()
|
| 105 |
logging.warning(f"Returned error: {exc_type.__name__}")
|
| 106 |
|
| 107 |
+
if response is None:
|
| 108 |
+
raise TranslationNotFound(text)
|
| 109 |
+
|
| 110 |
# Where Microsoft API responds with an api error, it returns a dict in response.json()
|
| 111 |
if type(response.json()) is dict:
|
| 112 |
error_message = response.json()["error"]
|
tests/test_microsoft_trans.py
CHANGED
|
@@ -36,10 +36,10 @@ def test_microsoft_successful_post_mock(mock_request_post):
|
|
| 36 |
|
| 37 |
|
| 38 |
def test_MicrosoftAPIerror():
|
| 39 |
-
with pytest.raises(exceptions.
|
| 40 |
-
MicrosoftTranslator(
|
| 41 |
-
|
| 42 |
-
)
|
| 43 |
|
| 44 |
|
| 45 |
# the remaining tests are actual requests to Microsoft API and use an api key
|
|
|
|
| 36 |
|
| 37 |
|
| 38 |
def test_MicrosoftAPIerror():
|
| 39 |
+
with pytest.raises(exceptions.ApiKeyException):
|
| 40 |
+
MicrosoftTranslator(api_key="", source="de", target="en").translate(
|
| 41 |
+
"text"
|
| 42 |
+
)
|
| 43 |
|
| 44 |
|
| 45 |
# the remaining tests are actual requests to Microsoft API and use an api key
|