[REF] small refactoring of rendering tests
bzr revid: xmo@openerp.com-20131021082223-5b0pv39b2ucdkpjf
This commit is contained in:
parent
5a257c5318
commit
dcc6259c7c
|
@ -4,7 +4,6 @@ from xml.dom import minidom as dom
|
|||
|
||||
import common
|
||||
from openerp.addons.base.ir import ir_qweb
|
||||
import openerp.addons.base.ir.ir_qweb
|
||||
|
||||
impl = dom.getDOMImplementation()
|
||||
document = impl.createDocument(None, None, None)
|
||||
|
@ -14,6 +13,9 @@ class TestQWebTField(common.TransactionCase):
|
|||
super(TestQWebTField, self).setUp()
|
||||
self.engine = self.registry('ir.qweb')
|
||||
|
||||
def context(self, values):
|
||||
return ir_qweb.QWebContext(self.cr, self.uid, values)
|
||||
|
||||
def test_trivial(self):
|
||||
field = document.createElement('span')
|
||||
field.setAttribute('t-field', u'company.name')
|
||||
|
@ -22,12 +24,9 @@ class TestQWebTField(common.TransactionCase):
|
|||
company_id = Companies.create(self.cr, self.uid, {
|
||||
'name': "My Test Company"
|
||||
})
|
||||
root_company = Companies.browse(self.cr, self.uid, company_id)
|
||||
|
||||
result = self.engine.render_node(field, ir_qweb.QWebContext(
|
||||
self.cr, self.uid, {
|
||||
'company': root_company,
|
||||
}))
|
||||
result = self.engine.render_node(field, self.context({
|
||||
'company': Companies.browse(self.cr, self.uid, company_id),
|
||||
}))
|
||||
|
||||
self.assertEqual(
|
||||
result,
|
||||
|
@ -46,12 +45,10 @@ class TestQWebTField(common.TransactionCase):
|
|||
company_id = Companies.create(self.cr, self.uid, {
|
||||
'name': s,
|
||||
})
|
||||
root_company = Companies.browse(self.cr, self.uid, company_id)
|
||||
result = self.engine.render_node(field, self.context({
|
||||
'company': Companies.browse(self.cr, self.uid, company_id),
|
||||
}))
|
||||
|
||||
result = self.engine.render_node(field, ir_qweb.QWebContext(
|
||||
self.cr, self.uid, {
|
||||
'company': root_company,
|
||||
}))
|
||||
self.assertEqual(
|
||||
result,
|
||||
'<span data-oe-model="res.company" data-oe-id="%d" '
|
||||
|
@ -67,8 +64,9 @@ class TestQWebTField(common.TransactionCase):
|
|||
with self.assertRaisesRegexp(
|
||||
AssertionError,
|
||||
r'^RTE widgets do not work correctly'):
|
||||
self.engine.render_node(field, ir_qweb.QWebContext(
|
||||
self.cr, self.uid, {'company': None}))
|
||||
self.engine.render_node(field, self.context({
|
||||
'company': None
|
||||
}))
|
||||
|
||||
def test_reject_t_tag(self):
|
||||
field = document.createElement('t')
|
||||
|
@ -77,5 +75,6 @@ class TestQWebTField(common.TransactionCase):
|
|||
with self.assertRaisesRegexp(
|
||||
AssertionError,
|
||||
r'^t-field can not be used on a t element'):
|
||||
self.engine.render_node(field, ir_qweb.QWebContext(
|
||||
self.cr, self.uid, {'company': None}))
|
||||
self.engine.render_node(field, self.context({
|
||||
'company': None
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue