Skip to content

Commit

Permalink
fix: poeditor config not available detection (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloge committed Feb 24, 2022
1 parent 0c1a3ec commit 5e67d8d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ v2.4.0
*Release date: In development*

- Add set_file_path and set_base64_path functions to dataset module, to set base paths for FILE and BASE64 mappings
- Fix detection of POEditor configuration not available

v2.3.0
------
Expand Down
16 changes: 15 additions & 1 deletion toolium/test/utils/test_poeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import mock

from toolium.utils.poeditor import get_valid_lang
from toolium.utils.poeditor import get_valid_lang, load_poeditor_texts


def test_poe_lang_param():
Expand All @@ -31,3 +31,17 @@ def test_poe_lang_param():
assert get_valid_lang(context, 'es') == 'es'
assert get_valid_lang(context, 'es-es') == 'es'
assert get_valid_lang(context, 'es-co') == 'es-co'


class ContextLogger(object):
def __init__(self):
self.logger = mock.MagicMock()


def test_poe_texts_load_without_api_token():
"""
Verification of POEditor texts load abortion when api_token is not configured
"""
context = ContextLogger()
load_poeditor_texts(context)
context.logger.info.assert_called_with("POEditor is not configured")
5 changes: 4 additions & 1 deletion toolium/utils/poeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,5 +329,8 @@ def get_poeditor_api_token(context):
try:
api_token = os.environ['poeditor_api_token']
except KeyError:
api_token = map_param('[CONF:poeditor.api_token]', context)
try:
api_token = context.project_config['poeditor']['api_token']
except (AttributeError, KeyError):
api_token = None
return api_token

0 comments on commit 5e67d8d

Please sign in to comment.