'Test saving html special chars in text nodes'

def test_save_escaped_text(self):

    view = self.env['ir.ui.view'].create({'arch': '<t    t-name="dummy"><p><h1>hello    world</h1></p></t>', 'type': 'qweb'})
    replacement = '<script>1    &&    "hello    &    world"</script>'
    view.save(replacement, xpath='/t/p/h1')
    self.assertIn(replacement.replace('&', '&amp;'), view.arch, 'inline    script    should    be    escaped    server    side')
    self.assertIn(replacement, view.render(), 'inline    script    should    not    be    escaped    when    rendering')
    replacement = 'world    &amp;amp;    &amp;lt;b&amp;gt;cie'
    view.save(replacement, xpath='/t/p')
    self.assertIn(replacement, view.arch, 'common    text    node    should    not    be    escaped    server    side')
    self.assertIn(replacement, view.render().replace('&', '&amp;'), 'text    node    characters    wrongly    unescaped    when    rendering')
