diff --git a/.travis.yml b/.travis.yml index f9348e7..659395e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,8 +80,7 @@ install: - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - travis_install_nightly - pip install -e . - - mv tests/test_helper test_helper - - mv tests/test_helper_bis test_helper_bis + - mv tests/test_helper* . script: - travis_run_tests diff --git a/tests/test_helper_extended/__init__.py b/tests/test_helper_extended/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/tests/test_helper_extended/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/tests/test_helper_extended/__manifest__.py b/tests/test_helper_extended/__manifest__.py new file mode 100644 index 0000000..1043ce3 --- /dev/null +++ b/tests/test_helper_extended/__manifest__.py @@ -0,0 +1,19 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + + +{ + "name": "Test Helper Extended", + "summary": "Another fake module extending fake module Test Helper for testing", + "version": "0.0.0", + "category": "Uncategorized", + "website": "www.akretion.com", + "author": " Akretion", + "license": "LGPL-3", + "application": False, + "installable": True, + "external_dependencies": {"python": [], "bin": []}, + "depends": ["test_helper"], + "data": [], + "demo": [], + "qweb": [], +} diff --git a/tests/test_helper_extended/models/__init__.py b/tests/test_helper_extended/models/__init__.py new file mode 100644 index 0000000..34dd130 --- /dev/null +++ b/tests/test_helper_extended/models/__init__.py @@ -0,0 +1 @@ +from . import test_mixin diff --git a/tests/test_helper_extended/models/test_mixin.py b/tests/test_helper_extended/models/test_mixin.py new file mode 100644 index 0000000..b9bc1dd --- /dev/null +++ b/tests/test_helper_extended/models/test_mixin.py @@ -0,0 +1,10 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo import fields, models + + +class TestMixin(models.AbstractModel): + _inherit = "test.mixin" + _description = "Test Mixin Extension" + + test_char_02 = fields.Char() diff --git a/tests/test_helper_extended/tests/__init__.py b/tests/test_helper_extended/tests/__init__.py new file mode 100644 index 0000000..ff72a1f --- /dev/null +++ b/tests/test_helper_extended/tests/__init__.py @@ -0,0 +1 @@ +from . import test_registry diff --git a/tests/test_helper_extended/tests/test_registry.py b/tests/test_helper_extended/tests/test_registry.py new file mode 100644 index 0000000..4b831e3 --- /dev/null +++ b/tests/test_helper_extended/tests/test_registry.py @@ -0,0 +1,33 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). + +from odoo.release import version_info + +if version_info[0] >= 15: + from odoo.tests import TransactionCase + + from odoo_test_helper import FakeModelLoader + + class TestMixin(TransactionCase): + def test_mixin_after_reloading_parent_module(self): + self.assertIn("test.mixin", self.env.registry) + self.assertIn("test_char", self.env["test.mixin"]._fields) + self.assertIn("test_char_02", self.env["test.mixin"]._fields) + + loader = FakeModelLoader(self.env, "odoo.addons.test_helper") + loader.backup_registry() + + # trigger reload of parent module: test_helper + loader.update_registry(()) + + self.assertIn("test.mixin", self.env.registry) + self.assertIn("test_char", self.env["test.mixin"]._fields) + # new field should not be there anymore + self.assertNotIn("test_char_02", self.env["test.mixin"]._fields) + + # but now we restore registry + loader.restore_registry() + + self.assertIn("test.mixin", self.env.registry) + self.assertIn("test_char", self.env["test.mixin"]._fields) + # new field should be there again + self.assertIn("test_char_02", self.env["test.mixin"]._fields)