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

Unified Diff: tests/test_translations.py

Issue 29693633: Noissue - Add crowdin api config support (Closed) Base URL: https://hg.adblockplus.org/cms
Patch Set: implement named tuples Created Feb. 18, 2018, 10:20 a.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
« tests/crowdin_mock_api.py ('K') | « tests/crowdin_mock_api.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/test_translations.py
===================================================================
--- a/tests/test_translations.py
+++ b/tests/test_translations.py
@@ -1,52 +1,58 @@
import os
import shutil
import pytest
+import zipfile
+
from wsgi_intercept import urllib3_intercept
from wsgi_intercept import add_wsgi_intercept
from wsgi_intercept import remove_wsgi_intercept
-from crowdin_mock_api import app
+from crowdin_mock_api import CrowdinMock
from cms.bin import translate
@pytest.fixture(scope='module')
def expect_requests():
return [
('info?key=test_key&json=1', ''),
('supported-languages?key=test_key&json=1', ''),
- ('add-file?key=test_key&json=1', 'translate.json'),
+ ('add-file?key=test_key&json=1', '.json'),
('upload-translation?key=test_key&json=1', 'simple'),
- ('delete-file?key=test_key&json=1', 'translate.json'),
- ('delete-file?key=test_key&json=1', 'translate.json'),
+ ('delete-file?key=test_key&json=1', '.json'),
+ ('delete-file?key=test_key&json=1', '.json'),
+ ('delete-file?key=test_key&json=1', '.json'),
+ ('delete-file?key=test_key&json=1', '.json'),
('delete-directory?key=test_key&json=1', ''),
('delete-directory?key=test_key&json=1', ''),
('export?key=test_key&json=1', ''),
('download/all.zip?key=test_key', ''),
]
@pytest.fixture(scope='module')
-def make_crowdin_zip(temp_site):
- zip_name = os.path.join('tests', 'all')
+def api_zip(temp_site, request):
+ zip_name = 'all'
input_dir = os.path.join(temp_site, 'locales')
shutil.make_archive(zip_name, 'zip', input_dir)
- yield None
+ yield zipfile.ZipFile(zip_name + '.zip')
Vasily Kuznetsov 2018/03/05 17:21:33 It seems like this zipfile object is not used anyw
Jon Sonesen 2018/03/06 02:30:19 Acknowledged.
os.remove(zip_name + '.zip')
Vasily Kuznetsov 2018/03/05 17:21:33 You could put this file into a temporary directory
Jon Sonesen 2018/03/06 02:30:18 Acknowledged.
-@pytest.fixture()
-def make_intercept(scope='module'):
+@pytest.fixture(scope='session')
+def mock_api(temp_site):
Vasily Kuznetsov 2018/03/05 17:21:33 The `CrowdinMock` has a hidden dependency from the
Jon Sonesen 2018/03/06 02:30:19 Acknowledged.
+ api = CrowdinMock(os.path.join(temp_site, 'locales'))
+ api.run()
host = 'api.crowdin.com'
port = 443
urllib3_intercept.install()
- add_wsgi_intercept(host, port, lambda: app.wsgi_app)
- yield None
+ add_wsgi_intercept(host, port, lambda: api.app.wsgi_app)
+ yield api
remove_wsgi_intercept()
-def test_sync(temp_site, make_intercept, make_crowdin_zip, expect_requests):
+def test_sync(temp_site, mock_api, api_zip, expect_requests):
translate.crowdin_sync(temp_site, 'test_key')
- for (url, data), (expect_url, expect_data) in zip(app.request_log,
+ for (url, data), (expect_url, expect_data) in zip(mock_api.app.request_log,
expect_requests):
assert expect_url in url
assert expect_data in data
« tests/crowdin_mock_api.py ('K') | « tests/crowdin_mock_api.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld