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

Unified Diff: tests/utils.py

Issue 29908581: Issue #7036 - [XTM Integration] Add support for providing workflow name (Closed)
Patch Set: Addressed comments from Patch Set 1 Created Oct. 18, 2018, 4:23 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
« no previous file with comments | « tests/test_xtm_translations_utils.py ('k') | tests/xtm_mock_api.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/utils.py
diff --git a/tests/utils.py b/tests/utils.py
index ed21e24c650e59651cd2a6edcf9d1cd915c9a38e..670442e6ca6b920ee7aab11e98f82218f2c56ff0 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -23,6 +23,10 @@ from io import BytesIO
import pytest
+from cms.translations.xtm.projects_handler import (
+ create_project, upload_files, download_files,
+)
+
def get_dir_contents(path):
# TODO: This function is duplicated in test_page_outputs.py.
@@ -80,7 +84,50 @@ def create_in_memory_zip(file_names, file_data):
def exception_test(func, exception, exp_msg, *args, **kw):
+ """Test if a function raises the correct exception.
+
+ Parameters
+ ----------
+ func: function
+ The function we're testing.
+ exception: classobj
+ The exception we expect to be raised.
+ exp_msg: str
+ The message we expect the exception to contain.
+
+ """
with pytest.raises(exception) as err:
func(*args, **kw)
assert exp_msg in str(err.value)
+
+
+class XtmMockArgs:
+ """Mock arguments for the XTM integration script."""
Vasily Kuznetsov 2018/10/19 12:47:28 Yay, docstrings!
+
+ class CreationArgsNamespace:
+ """Mock arguments for creating a new XTM project."""
+
+ name = 'bar'
+ desc = 'foo'
+ client_id = 10
+ ref_id = 'faz'
+ workflow_id = 20
+ save_id = False
+ source_dir = None
+ projects_func = staticmethod(create_project)
+ source_lang = 'en_US'
+ workflow_name = None
+
+ class UploadArgsNamespace:
+ """Mock arguments for uploading files to XTM for translation."""
+
+ source_dir = None
+ projects_func = staticmethod(upload_files)
+ no_overwrite = False
+
+ class DownloadArgsNamespace:
+ """Mock arguments for downloading translation from XTM."""
+
+ source_dir = None
+ projects_func = staticmethod(download_files)
« no previous file with comments | « tests/test_xtm_translations_utils.py ('k') | tests/xtm_mock_api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld