-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] test_helper_extended: extends test_helper with one more field i…
…n test.mixin
- Loading branch information
1 parent
9ccb57d
commit 04987cd
Showing
7 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_mixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class TestMixin(models.AbstractModel): | ||
_inherit = "test.mixin" | ||
_description = "Test Mixin Extension" | ||
|
||
test_char_02 = fields.Char() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_registry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# 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 SavepointCase as TransactionCase | ||
else: | ||
# Odoo 15 and later: TransactionCase rolls back between tests | ||
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) |