Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: tests/test_xtm_translations_utils.py

Issue 29908581: Issue #7036 - [XTM Integration] Add support for providing workflow name (Closed)
Patch Set: Created Oct. 12, 2018, 2:03 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/test_xtm_translations_utils.py
diff --git a/tests/test_xtm_translations_utils.py b/tests/test_xtm_translations_utils.py
index 6cd5def9bd89fd248fecb23fa6c374f4054d0f29..02c315d5f315f312e4f0905e40abcd3b30dafaa6 100644
--- a/tests/test_xtm_translations_utils.py
+++ b/tests/test_xtm_translations_utils.py
@@ -22,9 +22,9 @@ from cms.translations.xtm import utils
import cms.translations.xtm.constants as const
from cms.sources import FileSource
from cms.translations.xtm.xtm_api import XTMCloudAPI
-from tests.utils import exception_test
+from tests.utils import exception_test, XtmMockArgs
-_API_TOKEN = 'TheXTM-APIToken-VALID'
+_API_TOKEN_VALID = 'TheXTM-APIToken-VALID'
_PROJECT_ID = 1234
@@ -156,7 +156,7 @@ def test_resolve_locales(intercept_populated, temp_site):
In this environment, no languages have to be added.
"""
- api = XTMCloudAPI(_API_TOKEN)
+ api = XTMCloudAPI(_API_TOKEN_VALID)
source = FileSource(str(temp_site))
source.write_to_config('XTM', 'project_id', str(_PROJECT_ID))
@@ -168,7 +168,7 @@ def test_resolve_locales_adds_langs(intercept, temp_site):
In this environment, new target languages are added.
"""
- api = XTMCloudAPI(_API_TOKEN)
+ api = XTMCloudAPI(_API_TOKEN_VALID)
source = FileSource(str(temp_site))
source.write_to_config('XTM', 'project_id', str(_PROJECT_ID))
exp_targets = {'de_DE'}
@@ -184,7 +184,7 @@ def test_resolve_locales_raise_exception(intercept_populated, temp_site):
In this environment, the API has more target languages configured than are
available online. We except an exception to be raised.
"""
- api = XTMCloudAPI(_API_TOKEN)
+ api = XTMCloudAPI(_API_TOKEN_VALID)
api.add_target_languages(_PROJECT_ID, ['ro_RO'])
source = FileSource(str(temp_site))
source.write_to_config('XTM', 'project_id', str(_PROJECT_ID))
@@ -219,3 +219,29 @@ def test_write_data(toydir, path):
utils.write_to_file(data, str(toydir.join(path)))
assert toydir.join(path).read('rb') == data
+
+
+@pytest.mark.parametrize('id_in,name,exp_err,exp_msg,exp_id', [
+ (1234, 'foo', Exception,
+ const.ErrorMessages.WORKFLOW_NAME_AND_ID_PROVIDED, None),
+ (None, None, Exception, const.ErrorMessages.NO_WORKFLOW_INFO, None),
+ (None, 'foo', Exception,
+ const.ErrorMessages.NO_WORKFLOW_FOR_NAME.format('foo'), None),
+ (1234, None, None, None, 1234),
+ (None, 'workflow1', None, None, 2222),
+])
+def test_handle_workflows(intercept, id_in, name, exp_err, exp_msg, exp_id):
+ """"""
+ namespace = XtmMockArgs.CreationArgsNamespace()
+ namespace.workflow_id = id_in
+ namespace.workflow_name = name
+
+ api = XTMCloudAPI(_API_TOKEN_VALID)
+
+ if exp_err:
+ exception_test(utils.extract_workflow_id, exp_err, exp_msg, api,
+ namespace)
+ else:
+ id_out = utils.extract_workflow_id(api, namespace)
+
+ assert id_out == exp_id

Powered by Google App Engine
This is Rietveld