From b9219b05c98f0929195ebed9f157b51b2646f8c7 Mon Sep 17 00:00:00 2001 From: Sylvain Calador Date: Tue, 9 Feb 2016 17:38:28 +0100 Subject: [PATCH] [IMP] Add tests --- save_translation_file/tests/__init__.py | 5 +++ .../tests/test_save_translation_file.py | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 save_translation_file/tests/__init__.py create mode 100644 save_translation_file/tests/test_save_translation_file.py diff --git a/save_translation_file/tests/__init__.py b/save_translation_file/tests/__init__.py new file mode 100644 index 000000000..4c0c5a2c0 --- /dev/null +++ b/save_translation_file/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016-TODAY Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_save_translation_file diff --git a/save_translation_file/tests/test_save_translation_file.py b/save_translation_file/tests/test_save_translation_file.py new file mode 100644 index 000000000..36ba7b440 --- /dev/null +++ b/save_translation_file/tests/test_save_translation_file.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# © 2016-TODAY Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import os + +from openerp.modules import get_module_path +from openerp.tools.misc import get_iso_codes +from openerp.tools.translate import load_language +import openerp.tests.common as common + + +class TestIrModuleModule(common.TransactionCase): + + def test_button_save_translation(self): + + load_language(self.cr, 'fr_FR') + + condition = [('name', '=', 'save_translation_file')] + record = self.env['ir.module.module'].search(condition) + record.button_save_translation() + + i18n_path = os.path.join(get_module_path(record.name), 'i18n') + lang_obj = self.env['res.lang'] + condition = [('translatable', '=', True), ('code', '!=', 'en_US')] + langs = lang_obj.search(condition) + + for lang in langs: + iso_code = get_iso_codes(lang.code) + path = os.path.join(i18n_path, '%s.po' % iso_code) + self.assertEqual(os.path.isfile(path), True, + '%s.po must exists' % iso_code)