summaryrefslogtreecommitdiff
path: root/odoo/addons/test_documentation_examples/tests
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2016-09-02 15:58:39 +0200
committerRaphael Collet <rco@openerp.com>2016-09-02 17:28:12 +0200
commit9e64f9f9514194d74e166b032add8511182f2677 (patch)
tree5086710c04c6b923be18a6d1d97b3f0f3a2a9c4a /odoo/addons/test_documentation_examples/tests
parent11812b0b9e82b2b1b9041d8250ce01e7b4a5f7ee (diff)
[REF] openerp: move `openerp` to `odoo`
Diffstat (limited to 'odoo/addons/test_documentation_examples/tests')
-rw-r--r--odoo/addons/test_documentation_examples/tests/__init__.py4
-rw-r--r--odoo/addons/test_documentation_examples/tests/test_delegation.py39
-rw-r--r--odoo/addons/test_documentation_examples/tests/test_extension.py16
-rw-r--r--odoo/addons/test_documentation_examples/tests/test_inheritance.py14
4 files changed, 73 insertions, 0 deletions
diff --git a/odoo/addons/test_documentation_examples/tests/__init__.py b/odoo/addons/test_documentation_examples/tests/__init__.py
new file mode 100644
index 00000000000..a6ef30e7b07
--- /dev/null
+++ b/odoo/addons/test_documentation_examples/tests/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import test_inheritance, test_extension, test_delegation
diff --git a/odoo/addons/test_documentation_examples/tests/test_delegation.py b/odoo/addons/test_documentation_examples/tests/test_delegation.py
new file mode 100644
index 00000000000..90279f24208
--- /dev/null
+++ b/odoo/addons/test_documentation_examples/tests/test_delegation.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.tests import common
+
+class TestDelegation(common.TransactionCase):
+
+ def setUp(self):
+ super(TestDelegation, self).setUp()
+ env = self.env
+ record = env['delegation.parent'].create({
+ 'child0_id': env['delegation.child0'].create({'field_0': 0}).id,
+ 'child1_id': env['delegation.child1'].create({'field_1': 1}).id,
+ })
+ self.record = record
+
+ def test_delegating_record(self):
+ env = self.env
+ record = self.record
+
+ # children fields can be looked up on the parent record directly
+ self.assertEqual(record.field_0, 0)
+ self.assertEqual(record.field_1, 1)
+
+ def test_swap_child(self):
+ env = self.env
+ record = self.record
+
+ record.write({
+ 'child0_id': env['delegation.child0'].create({'field_0': 42}).id
+ })
+ self.assertEqual(record.field_0, 42)
+
+ def test_write(self):
+ record = self.record
+
+ record.write({'field_1': 4})
+ self.assertEqual(record.field_1, 4)
+ self.assertEqual(record.child1_id.field_1, 4)
diff --git a/odoo/addons/test_documentation_examples/tests/test_extension.py b/odoo/addons/test_documentation_examples/tests/test_extension.py
new file mode 100644
index 00000000000..e005f835586
--- /dev/null
+++ b/odoo/addons/test_documentation_examples/tests/test_extension.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.tests import common
+
+class TestBasicInheritance(common.TransactionCase):
+ def test_extend_fields(self):
+ env = self.env
+
+ record = env['extension.0'].create({})
+
+ self.assertDictContainsSubset(
+ {'name': "A", 'description': "Extended"}
+ ,
+ record.read()[0]
+ )
diff --git a/odoo/addons/test_documentation_examples/tests/test_inheritance.py b/odoo/addons/test_documentation_examples/tests/test_inheritance.py
new file mode 100644
index 00000000000..699c6b98ed2
--- /dev/null
+++ b/odoo/addons/test_documentation_examples/tests/test_inheritance.py
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.tests import common
+
+class TestBasicInheritance(common.TransactionCase):
+ def test_inherit_method(self):
+ env = self.env
+
+ a = env['inheritance.0'].create({'name': 'A'})
+ b = env['inheritance.1'].create({'name': 'B'})
+
+ self.assertEqual(a.call(), "This is model 0 record A")
+ self.assertEqual(b.call(), "This is model 1 record B")