OLD | NEW |
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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 from io import BytesIO | 22 from io import BytesIO |
23 import urllib2 | 23 import urllib2 |
24 | 24 |
25 import pytest | 25 import pytest |
26 | 26 |
27 from cms.translations.xtm.projects_handler import ( | 27 from cms.translations.xtm.projects_handler import ( |
28 create_project, upload_files, download_files, | 28 create_project, upload_files, download_files, |
29 ) | 29 ) |
30 | 30 |
31 | 31 |
32 def get_dir_contents(path): | 32 def get_dir_contents(path, test_type=False): |
33 # TODO: This function is duplicated in test_page_outputs.py. | 33 # TODO: This function is duplicated in test_page_outputs.py. |
34 dirdata = {} | 34 dirdata = {} |
35 for dirpath, dirnames, filenames in os.walk(path): | 35 for dirpath, dirnames, filenames in os.walk(path): |
36 for output_file in filenames: | 36 for output_file in filenames: |
37 filepath = os.path.join(dirpath, output_file) | 37 filepath = os.path.join(dirpath, output_file) |
38 with open(filepath) as f: | 38 with open(filepath) as f: |
39 locale = os.path.split(os.path.split(filepath)[0])[1] | 39 if test_type: |
40 dirdata[os.path.join(locale, output_file)] = f.read().strip() | 40 locale = os.path.split(os.path.split(os.path.split |
| 41 (filepath)[0])[0])[1] |
| 42 test_type = os.path.split(os.path.split(filepath)[0])[1] |
| 43 dirdata[os.path.join(locale, test_type, |
| 44 output_file)] = f.read().strip() |
| 45 else: |
| 46 locale = os.path.split(os.path.split(filepath)[0])[1] |
| 47 dirdata[os.path.join(locale, |
| 48 output_file)] = f.read().strip() |
41 return dirdata | 49 return dirdata |
42 | 50 |
43 | 51 |
44 @contextlib.contextmanager | 52 @contextlib.contextmanager |
45 def run_test_server(site_path, new_env=None): | 53 def run_test_server(site_path, new_env=None): |
46 """Run test server, yield its URL. Terminate server on next iteration. | 54 """Run test server, yield its URL. Terminate server on next iteration. |
47 | 55 |
48 This function is intended be used in a pytest fixture. | 56 This function is intended be used in a pytest fixture. |
49 | 57 |
50 Parameters | 58 Parameters |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 175 |
168 source_dir = None | 176 source_dir = None |
169 projects_func = staticmethod(upload_files) | 177 projects_func = staticmethod(upload_files) |
170 no_overwrite = False | 178 no_overwrite = False |
171 | 179 |
172 class DownloadArgsNamespace: | 180 class DownloadArgsNamespace: |
173 """Mock arguments for downloading translation from XTM.""" | 181 """Mock arguments for downloading translation from XTM.""" |
174 | 182 |
175 source_dir = None | 183 source_dir = None |
176 projects_func = staticmethod(download_files) | 184 projects_func = staticmethod(download_files) |
OLD | NEW |