'Checks that the branding is correctly distributed within a view
extension'

def test_branding_distribute_inner(self):

    view1 = self.View.create({'name': 'Base    view', 'type': 'qweb', 'arch': '<root>\n                                                                <item    order="1"/>\n                                                </root>'})
    view2 = self.View.create({'name': 'Extension', 'type': 'qweb', 'inherit_id': view1.id, 'arch': '<xpath    expr="//item"    position="before">\n                                                                <item    order="2">\n                                                                                <content    t-att-href="foo">bar</content>\n                                                                </item>\n                                                </xpath>'})
    arch_string = view1.with_context(inherit_branding=True).read_combined(['arch'])['arch']
    arch = etree.fromstring(arch_string)
    self.View.distribute_branding(arch)
    self.assertEqual(arch, E.root(E.item(E.content('bar', {'t-att-href': 'foo', 'data-oe-model': 'ir.ui.view', 'data-oe-id': str(view2.id), 'data-oe-field': 'arch', 'data-oe-xpath': '/xpath/item/content[1]'}), {'order': '2'}), E.item({'order': '1', 'data-oe-model': 'ir.ui.view', 'data-oe-id': str(view1.id), 'data-oe-field': 'arch', 'data-oe-xpath': '/root[1]/item[1]'})))
