Skip to content
Snippets Groups Projects
Commit 665edd10 authored by Victor Feyens's avatar Victor Feyens Committed by Antoine Vandevenne (anv)
Browse files

[REM] core: remove `test_documentation_examples` module

The only purpose of the module `test_documentation_examples` is to test
a few of the code examples shown in the developer documentation.

As c99629b7de3 removes the documentation sources from the repository,
the test module is removed as well.

DOC PR: https://github.com/odoo/documentation-user/pull/945



task-2352371

closes odoo/odoo#70121

Signed-off-by: default avatarMartin Trigaux (mat) <mat@odoo.com>
Co-authored-by: default avatarVictor Feyens <vfe@odoo.com>
Co-authored-by: default avatarAntoine Vandevenne <anv@odoo.com>
parent 0e40494b
No related branches found
No related tags found
No related merge requests found
Showing with 0 additions and 185 deletions
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import inheritance
from . import extension
from . import delegation
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': "Documentation examples test",
'description': """
Contains pieces of code to be used as technical documentation examples
(via the ``literalinclude`` directive) in situations where they can be
syntax-checked and tested.
""",
'category': 'Tests',
'version': '0.1',
'data': [
'ir.model.access.csv',
],
}
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields
class Child0(models.Model):
_name = 'delegation.child0'
_description = 'Delegation Child zero'
field_0 = fields.Integer()
class Child1(models.Model):
_name = 'delegation.child1'
_description = 'Delegation Child one'
field_1 = fields.Integer()
class Delegating(models.Model):
_name = 'delegation.parent'
_description = 'Delegation Parent'
_inherits = {
'delegation.child0': 'child0_id',
'delegation.child1': 'child1_id',
}
child0_id = fields.Many2one('delegation.child0', required=True, ondelete='cascade')
child1_id = fields.Many2one('delegation.child1', required=True, ondelete='cascade')
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields
class Extension0(models.Model):
_name = 'extension.0'
_description = 'Extension zero'
name = fields.Char(default="A")
class Extension1(models.Model):
_inherit = 'extension.0'
description = fields.Char(default="Extended")
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields
class Inheritance0(models.Model):
_name = 'inheritance.0'
_description = 'Inheritance Zero'
name = fields.Char()
def call(self):
return self.check("model 0")
def check(self, s):
return "This is {} record {}".format(s, self.name)
class Inheritance1(models.Model):
_name = 'inheritance.1'
_inherit = 'inheritance.0'
_description = 'Inheritance One'
def call(self):
return self.check("model 1")
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_inheritance_0,access_inheritance_0,model_inheritance_0,,1,1,1,1
access_inheritance_1,access_inheritance_1,model_inheritance_1,,1,1,1,1
access_extension_0,access_extension_0,model_extension_0,,1,1,1,1
access_delegation_child0,access_delegation_child0,model_delegation_child0,,1,1,1,1
access_delegation_child1,access_delegation_child1,model_delegation_child1,,1,1,1,1
access_delegation_parent,access_delegation_parent,model_delegation_parent,,1,1,1,1
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import test_inheritance, test_extension, test_delegation
# -*- 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)
# -*- 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]
)
# -*- 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"
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment