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

Unified Diff: tests/test_translations.py

Issue 29355396: Issue 4380 - Add Mock Crowdin API and Sync Test (Closed)
Patch Set: Add basic assertion for sync test Created Oct. 5, 2016, 3:50 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
Index: tests/test_translations.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/tests/test_translations.py
@@ -0,0 +1,34 @@
+import os
+import shutil
+import pytest
+import mock_api
+from wsgi_intercept import urllib3_intercept
+from wsgi_intercept import add_wsgi_intercept
+from wsgi_intercept import remove_wsgi_intercept
+
+from cms.bin import translate
+
+
+@pytest.fixture(scope='module')
+def make_crowdin_zip(temp_site):
+ zip_name = os.path.join('tests', 'all')
+ input_dir = os.path.join(temp_site, 'locales')
+ shutil.make_archive(zip_name, 'zip', input_dir)
+ yield None
+ os.remove(zip_name + '.zip')
+
+
+@pytest.fixture()
+def make_intercept(scope='module'):
+ host = 'api.crowdin.com'
+ port = 443
+ urllib3_intercept.install()
Sebastian Noack 2016/10/05 12:06:16 Wasn't the idea, to not mock the HTTP client libra
Jon Sonesen 2016/10/05 14:38:13 I believe that was the original plan but when impl
Vasily Kuznetsov 2016/10/05 14:44:42 We've decided to switch the approach to wsgi_inter
Sebastian Noack 2016/10/05 16:36:44 How is this any simpler or even less environment d
Vasily Kuznetsov 2016/10/06 09:38:59 You make some good points. Indeed it's pretty easy
Sebastian Noack 2016/10/06 10:25:26 I agree that it's not that great to require a part
Jon Sonesen 2016/10/08 02:21:40 Let's leave it with wsgi_intercept and if we find
+ add_wsgi_intercept(host, port, lambda: mock_api.app.wsgi_app)
+ yield None
+ remove_wsgi_intercept()
+
+
+def test_sync(temp_site, make_intercept, make_crowdin_zip):
+ translate.crowdin_sync(temp_site, 'test_key')
+ for data_set in mock_api.app.request_data.items():
+ assert data_set is not None
Jon Sonesen 2016/10/05 03:54:49 this is just a preliminary assertion. I am open to

Powered by Google App Engine
This is Rietveld