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

Delta Between Two Patch Sets: tests/test_xtm_api.py

Issue 29886648: Issue #6942 - Add XTM integration in CMS (Closed)
Left Patch Set: Addressed comments on patch set #2 Created Oct. 3, 2018, 2:50 p.m.
Right Patch Set: Addressed comments from Patch Set #4 Created Oct. 5, 2018, 4:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 """Tests for the XTM API integration.""" 16 """Tests for the XTM API integration."""
17 17
18 from __future__ import unicode_literals 18 from __future__ import unicode_literals
19 19
20 import json 20 import json
21 import zipfile 21 import zipfile
22 from io import BytesIO 22 from io import BytesIO
23 23
24 import pytest 24 import pytest
25 25
26 from cms.bin.xtm_translations.xtm_api import (XTMCloudException, XTMCloudAPI, 26 from cms.translations.xtm.xtm_api import (XTMCloudException, XTMCloudAPI,
27 get_token) 27 get_token)
28 from tests.utils import exception_test 28 from tests.utils import exception_test
29 29
30 _VALID_TOKEN = 'TheXTM-APIToken-VALID' 30 _VALID_TOKEN = 'TheXTM-APIToken-VALID'
31 _INVALID_TOKEN = 'TheXTM-APIToken-INVALID' 31 _INVALID_TOKEN = 'TheXTM-APIToken-INVALID'
32 32
33 _FILES_UPLOAD = {'test.json': json.dumps({'foo': 'bar'})} 33 _FILES_UPLOAD = {'test.json': json.dumps({'foo': 'bar'})}
34 _EXPECTED_JOBS = [{'fileName': 'test.json', 'jobId': 1, 34 _EXPECTED_JOBS = [{'fileName': 'test.json', 'jobId': 1,
35 'sourceLanguage': 'en_US', 'targetLanguage': 'de_DE'}] 35 'sourceLanguage': 'en_US', 'targetLanguage': 'de_DE'}]
36 36
37 37
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 (_VALID_TOKEN, 1234, _FILES_UPLOAD, None, None, _EXPECTED_JOBS), 131 (_VALID_TOKEN, 1234, _FILES_UPLOAD, None, None, _EXPECTED_JOBS),
132 ]) 132 ])
133 def test_file_upload(intercept, token, project_id, files, exp_err, exp_msg, 133 def test_file_upload(intercept, token, project_id, files, exp_err, exp_msg,
134 exp_jobs): 134 exp_jobs):
135 """Test file uploading.""" 135 """Test file uploading."""
136 api = XTMCloudAPI(token) 136 api = XTMCloudAPI(token)
137 if exp_msg is not None: 137 if exp_msg is not None:
138 exception_test(api.upload_files, exp_err, exp_msg, files, project_id) 138 exception_test(api.upload_files, exp_err, exp_msg, files, project_id)
139 else: 139 else:
140 assert exp_jobs == api.upload_files(files, project_id) 140 assert exp_jobs == api.upload_files(files, project_id)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld