summaryrefslogtreecommitdiff
path: root/addons/web/tests
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-12-02 10:18:33 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-12-04 13:06:54 +0000
commite237ba26f7fbe687ff87ed5311549671d5682515 (patch)
tree2bb0a4c450eca5ea3bc7fbc5e1eba30d011822be /addons/web/tests
parent96ab29c9873ee3d0f603068c6bc0c2d4056a3081 (diff)
[IMP]: web, tools: static inheritance do not disclose t-inherit* directives
Before this commit, when a template was inheriting from another the template mentionned its t-inherit This has been deemed overkill as the information is irrelevant to the caller i.e. the caller just wants the template and doesn't care how they've been computed After this commit, only t-name and attributes not related with inheritance are disclosed [FIX]: base: static inheritance propagates other attributes When doing a inherit in primary mode, the original attributes on the root node of the inheriting template were not propagated After this commit they are
Diffstat (limited to 'addons/web/tests')
-rw-r--r--addons/web/tests/test_serving_base.py92
1 files changed, 86 insertions, 6 deletions
diff --git a/addons/web/tests/test_serving_base.py b/addons/web/tests/test_serving_base.py
index 87c01d748dc..1279caf016a 100644
--- a/addons/web/tests/test_serving_base.py
+++ b/addons/web/tests/test_serving_base.py
@@ -144,7 +144,7 @@ class TestStaticInheritance(BaseCase):
<!-- Modified by anonymous_template_2 from module_2 -->
<div>And I learned how to get along</div>
</t>
- <form t-name="template_2_1" random-attr="gloria" t-inherit="module_1.template_1_1">
+ <form t-name="template_2_1" random-attr="gloria">
<div>At first I was afraid</div>
<div>I was petrified</div>
<div>But then I spent so many nights thinking how you did me wrong</div>
@@ -158,6 +158,86 @@ class TestStaticInheritance(BaseCase):
self.assertXMLEqual(contents, expected)
+ def test_static_inheritance_02(self):
+ self.template_files = {
+ 'module_1_file_1': b'''
+ <templates id="template" xml:space="preserve">
+ <form t-name="template_1_1" random-attr="gloria">
+ <div>At first I was afraid</div>
+ <div>Kept thinking I could never live without you by my side</div>
+ </form>
+ <form t-name="template_1_2" t-inherit="template_1_1" added="true">
+ <xpath expr="//div[1]" position="after">
+ <div>I was petrified</div>
+ </xpath>
+ </form>
+ </templates>
+ '''
+ }
+ self.modules = [
+ ('module_1_file_1', None, 'module_1'),
+ ]
+ contents = HomeStaticTemplateHelpers.get_qweb_templates(addons=self._get_module_names(), debug=True)
+ expected = b"""
+ <templates>
+ <form t-name="template_1_1" random-attr="gloria">
+ <div>At first I was afraid</div>
+ <div>Kept thinking I could never live without you by my side</div>
+ </form>
+ <form t-name="template_1_2" random-attr="gloria" added="true">
+ <div>At first I was afraid</div>
+ <div>I was petrified</div>
+ <div>Kept thinking I could never live without you by my side</div>
+ </form>
+ </templates>
+ """
+
+ self.assertXMLEqual(contents, expected)
+
+ def test_static_inheritance_03(self):
+ self.maxDiff = None
+ self.template_files = {
+ 'module_1_file_1': b'''
+ <templates id="template" xml:space="preserve">
+ <form t-name="template_1_1">
+ <div>At first I was afraid</div>
+ <div>Kept thinking I could never live without you by my side</div>
+ </form>
+ <form t-name="template_1_2" t-inherit="template_1_1" added="true">
+ <xpath expr="//div[1]" position="after">
+ <div>I was petrified</div>
+ </xpath>
+ </form>
+ <form t-name="template_1_3" t-inherit="template_1_2" added="false" other="here">
+ <xpath expr="//div[2]" position="replace"/>
+ </form>
+ </templates>
+ '''
+ }
+ self.modules = [
+ ('module_1_file_1', None, 'module_1'),
+ ]
+ contents = HomeStaticTemplateHelpers.get_qweb_templates(addons=self._get_module_names(), debug=True)
+ expected = b"""
+ <templates>
+ <form t-name="template_1_1">
+ <div>At first I was afraid</div>
+ <div>Kept thinking I could never live without you by my side</div>
+ </form>
+ <form t-name="template_1_2" added="true">
+ <div>At first I was afraid</div>
+ <div>I was petrified</div>
+ <div>Kept thinking I could never live without you by my side</div>
+ </form>
+ <form t-name="template_1_3" added="false" other="here">
+ <div>At first I was afraid</div>
+ <div>Kept thinking I could never live without you by my side</div>
+ </form>
+ </templates>
+ """
+
+ self.assertXMLEqual(contents, expected)
+
def test_static_inheritance_in_same_module(self):
self.modules = [
('module_1_file_1', None, 'module_1'),
@@ -191,7 +271,7 @@ class TestStaticInheritance(BaseCase):
<div>At first I was afraid</div>
<div>Kept thinking I could never live without you by my side</div>
</form>
- <form t-name="template_1_2" t-inherit="template_1_1">
+ <form t-name="template_1_2">
<div>At first I was afraid</div>
<div>I was petrified</div>
<div>Kept thinking I could never live without you by my side</div>
@@ -228,7 +308,7 @@ class TestStaticInheritance(BaseCase):
<div>At first I was afraid</div>
<div>Kept thinking I could never live without you by my side</div>
</form>
- <form t-name="template_1_2" t-inherit="template_1_1">
+ <form t-name="template_1_2">
<div>At first I was afraid</div>
<div>I was petrified</div>
<div>Kept thinking I could never live without you by my side</div>
@@ -271,7 +351,7 @@ class TestStaticInheritance(BaseCase):
<div>I was petrified</div>
<div>Kept thinking I could never live without you by my side</div>
</form>
- <form t-name="template_1_3" t-inherit="template_1_1">
+ <form t-name="template_1_3">
<div>At first I was afraid</div>
<div>I was petrified</div>
<div>Kept thinking I could never live without you by my side</div>
@@ -630,7 +710,7 @@ class TestStaticInheritance(BaseCase):
<div>At first I was afraid</div>
<form>Inner Form</form>
</form>
- <div t-name="template_1_2" t-inherit="template_1_1">
+ <div t-name="template_1_2">
Form replacer
</div>
</templates>
@@ -670,7 +750,7 @@ class TestStaticInheritance(BaseCase):
<form t-name="template_1_1" random-attr="gloria">
<div>At first I was afraid</div>
</form>
- <div overriden-attr="overriden" t-name="template_1_2" t-inherit="template_1_1">
+ <div overriden-attr="overriden" t-name="template_1_2">
And I grew strong
<p>And I learned how to get along</p>
</div>