summaryrefslogtreecommitdiff
path: root/odoo/tools/misc.py
diff options
context:
space:
mode:
authorRomain Derie <rde@odoo.com>2019-06-26 13:48:56 +0000
committerRomain Derie <rde@odoo.com>2019-06-26 17:08:09 +0000
commit6ebcb1db80eeb37ab7ac2f5a27a8c616f12b95b3 (patch)
treee5b099e61983f969a205d593cdd31b557306b722 /odoo/tools/misc.py
parentbb81e4ccd7b0044bbe1ad45842a3f799ceac0838 (diff)
[IMP] tool, website, website_sale: move test utils functions
We have multiple ways of simulating a frontend context while running python tests (mainly during TransactionCase): - `MockObject` class from 8557bcfa30 - `simulate_frontend_context` method from a5a5a57e48 - `DotDict` from f8efc9a957c28 This commit moves `MockObject` to misc to be reusable and adapt it to be accessible by dot notation with `DotDict`. Part of #34396
Diffstat (limited to 'odoo/tools/misc.py')
-rw-r--r--odoo/tools/misc.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py
index 762c07e535c..7d465356e10 100644
--- a/odoo/tools/misc.py
+++ b/odoo/tools/misc.py
@@ -1242,3 +1242,14 @@ def wrap_module(module, attr_list):
raise AttributeError(attrib)
# module and attr_list are in the closure
return WrappedModule()
+
+
+class DotDict(dict):
+ """Helper for dot.notation access to dictionary attributes
+ E.g.
+ foo = DotDict({'bar': False})
+ return foo.bar
+ """
+ def __getattr__(self, attrib):
+ val = self.get(attrib)
+ return DotDict(val) if type(val) is dict else val