[MIG] fix tests
Manual forward port of 11.0 migration commit by Thierry Ducrest.
This commit is contained in:
parent
5d77a38c31
commit
6495d9ffce
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2016 ACSONE SA/NV
|
||||
# Copyright 2016-2018 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
'version': '12.0.1.0.0',
|
||||
'license': 'AGPL-3',
|
||||
'author': 'ACSONE SA/NV, Odoo Community Association (OCA)',
|
||||
'website': 'https://odoo-community.org/',
|
||||
'website': 'https://github.com/OCA/server-env/',
|
||||
'depends': [
|
||||
'server_environment',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2016 ACSONE SA/NV
|
||||
# Copyright 2016-2018 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models, _
|
||||
|
|
@ -15,7 +15,7 @@ class IrConfigParameter(models.Model):
|
|||
|
||||
@api.model
|
||||
def get_param(self, key, default=False):
|
||||
value = super(IrConfigParameter, self).get_param(key, default=None)
|
||||
value = super().get_param(key, default=None)
|
||||
if serv_config.has_option(SECTION, key):
|
||||
cvalue = serv_config.get(SECTION, key)
|
||||
if not cvalue:
|
||||
|
|
@ -39,7 +39,7 @@ class IrConfigParameter(models.Model):
|
|||
if serv_config.has_option(SECTION, key):
|
||||
# enforce value from config file
|
||||
vals = dict(vals, value=serv_config.get(SECTION, key))
|
||||
return super(IrConfigParameter, self).create(vals)
|
||||
return super().create(vals)
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
|
|
@ -50,5 +50,5 @@ class IrConfigParameter(models.Model):
|
|||
newvals = dict(vals, value=serv_config.get(SECTION, key))
|
||||
else:
|
||||
newvals = vals
|
||||
super(IrConfigParameter, rec).write(newvals)
|
||||
super().write(newvals)
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
* Stéphane Bidoul <stephane.bidoul@acsone.eu> (https://acsone.eu)
|
||||
* Thierry Ducrest <thierry.ducrest@camptocamp.com>
|
||||
* Gilles Meyomesse <gilles.meyomesse@acsone.eu> (https://acsone.eu)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<odoo>
|
||||
<record model="ir.config_parameter" id="some_record_id">
|
||||
<field name="key">ircp_from_config</field>
|
||||
<field name="value">value_from_xml</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -1,19 +1,24 @@
|
|||
# Copyright 2016 ACSONE SA/NV
|
||||
# Copyright 2016-2018 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from cStringIO import StringIO
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests import common
|
||||
from odoo.tools import convert
|
||||
from odoo.tools import convert_file
|
||||
from odoo.modules.module import get_resource_path
|
||||
|
||||
|
||||
class TestEnv(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestEnv, self).setUp()
|
||||
super().setUp()
|
||||
self.ICP = self.env['ir.config_parameter']
|
||||
|
||||
def _load_xml(self, module, filepath):
|
||||
convert_file(
|
||||
self.env.cr, module,
|
||||
get_resource_path(module, filepath),
|
||||
{}, mode='init', noupdate=False, kind='test')
|
||||
|
||||
def test_get_param(self):
|
||||
""" Get system parameter from config """
|
||||
# it's not in db
|
||||
|
|
@ -67,14 +72,9 @@ class TestEnv(common.TransactionCase):
|
|||
self.assertEqual(self.ICP.get_param('ircp_nonexistant'), False)
|
||||
|
||||
def test_override_xmldata(self):
|
||||
xml = """<odoo>
|
||||
<data>
|
||||
<record model="ir.config_parameter" id="some_record_id">
|
||||
<field name="key">ircp_from_config</field>
|
||||
<field name="value">value_from_xml</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>"""
|
||||
convert.convert_xml_import(self.env.cr, 'testmodule', StringIO(xml))
|
||||
self._load_xml(
|
||||
'server_environment_ir_config_parameter',
|
||||
'tests/config_param_test.xml'
|
||||
)
|
||||
value = self.ICP.get_param('ircp_from_config')
|
||||
self.assertEqual(value, 'config_value')
|
||||
|
|
|
|||
Loading…
Reference in New Issue