[ADD] test_translation_import: export source terms
Add a test for exporting the source terms of modules. This will allow automated scripts to fetch latest terms Backport save_test_file with a parameter on date_format to have predictable filenames closes odoo/odoo#159373 X-original-commit: e7246ea48828746471a2e3a485bee30687eeee80 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import test_export_wizard
|
||||||
from . import test_term_count
|
from . import test_term_count
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import base64
|
||||||
|
from odoo.tests import common, tagged
|
||||||
|
|
||||||
|
|
||||||
|
@tagged("post_install", "-at_install", "-standard", "nightly_export")
|
||||||
|
class TestTranslationFlow(common.TransactionCase):
|
||||||
|
|
||||||
|
@common.no_retry
|
||||||
|
def test_export_source(self):
|
||||||
|
"""Export the source terms for every module and save it"""
|
||||||
|
|
||||||
|
for module in self.env["ir.module.module"].search([("state", "=", "installed")]):
|
||||||
|
export = self.env["base.language.export"].create({
|
||||||
|
"lang": "__new__",
|
||||||
|
"format": "po",
|
||||||
|
"modules": [(6, 0, [module.id])]
|
||||||
|
})
|
||||||
|
export.act_getfile()
|
||||||
|
pot_file = base64.b64decode(export.data)
|
||||||
|
common.save_test_file(
|
||||||
|
module.name, pot_file, prefix="i18n_", extension="pot",
|
||||||
|
document_type="Source Terms for %s" % module.name,
|
||||||
|
date_format="",
|
||||||
|
)
|
||||||
@@ -871,12 +871,11 @@ def fchain(future, next_callback):
|
|||||||
|
|
||||||
return new_future
|
return new_future
|
||||||
|
|
||||||
|
def save_test_file(test_name, content, prefix, extension='png', logger=_logger, document_type='Screenshot', date_format="%Y%m%d_%H%M%S_%f"):
|
||||||
def save_test_file(test_name, content, prefix, extension='png', logger=_logger, document_type='Screenshot'):
|
|
||||||
assert re.fullmatch(r'\w*_', prefix)
|
assert re.fullmatch(r'\w*_', prefix)
|
||||||
assert re.fullmatch(r'[a-z]+', extension)
|
assert re.fullmatch(r'[a-z]+', extension)
|
||||||
assert re.fullmatch(r'\w+', test_name)
|
assert re.fullmatch(r'\w+', test_name)
|
||||||
now = datetime.now().strftime("%Y%m%d_%H%M%S_%f")
|
now = datetime.now().strftime(date_format)
|
||||||
screenshots_dir = pathlib.Path(odoo.tools.config['screenshots']) / get_db_name() / 'screenshots'
|
screenshots_dir = pathlib.Path(odoo.tools.config['screenshots']) / get_db_name() / 'screenshots'
|
||||||
screenshots_dir.mkdir(parents=True, exist_ok=True)
|
screenshots_dir.mkdir(parents=True, exist_ok=True)
|
||||||
fname = f'{prefix}{now}_{test_name}.{extension}'
|
fname = f'{prefix}{now}_{test_name}.{extension}'
|
||||||
|
|||||||
Reference in New Issue
Block a user