Skip to content

Commit

Permalink
[IMP] website_lazy_load_image: Added Unitests
Browse files Browse the repository at this point in the history
  • Loading branch information
hugho-ad committed Jul 23, 2019
1 parent 4d0e932 commit 00edff0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions website_lazy_load_image/tests/test_lazy_load_image.py
Expand Up @@ -27,7 +27,7 @@ def setUpClass(cls):
'arch_base': arch_2,
'mode': 'primary'
})
arch_3 = 'content not wrapped'
arch_3 = '<t t-name="test"><span>content not wrapped</span></t>'
cls.view_3 = cls.env['ir.ui.view'].create({
'name': 'Test 3',
'key': 'website_lazy_load_image.test_3',
Expand Down Expand Up @@ -83,13 +83,18 @@ def test_no_wrap_content(self):
public_user_id = self.ref('base.public_user')
ui_view = self.env['ir.ui.view'].sudo(
public_user_id).with_context(website_id=self.website_id)
res = etree.HTML(ui_view.render_template(self.view_3.id))
self.assertEqual(res, self.arch_3)
res = ui_view.render_template(self.view_3.id).decode('UTF-8')
arch = '<span>content not wrapped</span>'
self.assertEqual(res, arch)

def test_encoding_render(self):
"""Check content is correctly enconded"""
public_user_id = self.ref('base.public_user')
ui_view = self.env['ir.ui.view'].sudo(
public_user_id).with_context(website_id=self.website_id)
res = etree.HTML(ui_view.render_template(self.view_4.id))
self.assertEqual(res, self.arch_4)
res = ui_view.render_template(self.view_4.id).decode('UTF-8')
arch = '<main><span>Teléfono, means phone</span></main>'
self.assertEqual(res, arch)
robots = self.env.ref('website.robots').render()
self.assertNotIn('<html>', robots.decode(
'UTF-8'), "Robots must not be wrapped into html DOM")

0 comments on commit 00edff0

Please sign in to comment.