OLD | NEW |
(Empty) | |
| 1 import os |
| 2 import shutil |
| 3 import pytest |
| 4 import crowdin_mock_api |
| 5 from wsgi_intercept import urllib3_intercept |
| 6 from wsgi_intercept import add_wsgi_intercept |
| 7 from wsgi_intercept import remove_wsgi_intercept |
| 8 |
| 9 from cms.bin import translate |
| 10 |
| 11 |
| 12 @pytest.fixture(scope='module') |
| 13 def make_crowdin_zip(temp_site): |
| 14 zip_name = os.path.join('tests', 'all') |
| 15 input_dir = os.path.join(temp_site, 'locales') |
| 16 shutil.make_archive(zip_name, 'zip', input_dir) |
| 17 yield None |
| 18 os.remove(zip_name + '.zip') |
| 19 |
| 20 |
| 21 @pytest.fixture() |
| 22 def make_intercept(scope='module'): |
| 23 host = 'api.crowdin.com' |
| 24 port = 443 |
| 25 urllib3_intercept.install() |
| 26 add_wsgi_intercept(host, port, lambda: crowdin_mock_api.app.wsgi_app) |
| 27 yield None |
| 28 remove_wsgi_intercept() |
| 29 |
| 30 |
| 31 def test_sync(temp_site, make_intercept, make_crowdin_zip): |
| 32 translate.crowdin_sync(temp_site, 'test_key') |
| 33 for data_set in crowdin_mock_api.app.request_data: |
| 34 assert data_set is not None |
OLD | NEW |