[REM] broken tests

expectation of view validation errors when creating view referencing
non-existent fields or models, but in website branch models and views
have become independents, these are not context-free errors anymore.

Also fix shit code.

bzr revid: xmo@openerp.com-20131007093328-gjrktqbsoe48ikol
This commit is contained in:
Xavier Morel 2013-10-07 11:33:28 +02:00
parent b94389dfca
commit e5d67ad2e0
1 changed files with 13 additions and 66 deletions

View File

@ -430,40 +430,6 @@ class TestNoModel(common.TransactionCase):
class test_views(common.TransactionCase):
@mute_logger('openerp.osv.orm', 'openerp.addons.base.ir.ir_ui_view')
def test_00_init_check_views(self):
Views = self.registry('ir.ui.view')
self.assertTrue(Views.pool._init)
error_msg = "The model name does not exist or the view architecture cannot be rendered"
# test arch check is call for views without xmlid during registry initialization
with self.assertRaisesRegexp(except_orm, error_msg):
Views.create(self.cr, self.uid, {
'name': 'Test View #1',
'model': 'ir.ui.view',
'arch': """<?xml version="1.0"?>
<tree>
<field name="test_1"/>
</tree>
""",
})
# same for inherited views
with self.assertRaisesRegexp(except_orm, error_msg):
# Views.pudb = True
Views.create(self.cr, self.uid, {
'name': 'Test View #2',
'model': 'ir.ui.view',
'inherit_id': self.browse_ref('base.view_view_tree').id,
'arch': """<?xml version="1.0"?>
<xpath expr="//field[@name='name']" position="after">
<field name="test_2"/>
</xpath>
""",
})
def _insert_view(self, **kw):
"""Insert view into database via a query to passtrough validation"""
kw.pop('id', None)
@ -483,47 +449,28 @@ class test_views(common.TransactionCase):
validate = partial(Views._validate_custom_views, self.cr, self.uid, model)
# validation of a single view
vid = self._insert_view(**{
'name': 'base view',
'model': model,
'priority': 1,
'arch': """<?xml version="1.0"?>
vid = self._insert_view(
name='base view',
model=model,
priority=1,
arch="""<?xml version="1.0"?>
<tree string="view">
<field name="url"/>
</tree>
""",
})
)
self.assertTrue(validate()) # single view
# validation of a inherited view
self._insert_view(**{
'name': 'inherited view',
'model': model,
'priority': 1,
'inherit_id': vid,
'arch': """<?xml version="1.0"?>
self._insert_view(
name='inherited view',
model=model,
priority=1,
inherit_id=vid,
arch="""<?xml version="1.0"?>
<xpath expr="//field[@name='url']" position="before">
<field name="name"/>
</xpath>
""",
})
)
self.assertTrue(validate()) # inherited view
# validation of a bad inherited view
self._insert_view(**{
'name': 'bad inherited view',
'model': model,
'priority': 2,
'inherit_id': vid,
'arch': """<?xml version="1.0"?>
<xpath expr="//field[@name='url']" position="after">
<field name="bad"/>
</xpath>
""",
})
with mute_logger('openerp.osv.orm', 'openerp.addons.base.ir.ir_ui_view'):
self.assertFalse(validate()) # bad inherited view
if __name__ == '__main__':
unittest2.main()