From 85f457323fedbce1b264482d08f790ddf815a502 Mon Sep 17 00:00:00 2001 From: Martin Macko Date: Sun, 3 Apr 2022 17:00:00 +0200 Subject: [PATCH] #334 Test fixed amend template tag context --- .../test_amend_tag_on_imported_content.html | 9 ++ poleno/utils/tests/test_templatetags.py | 111 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 poleno/utils/templates/utils/tests/amendtemplatetagtest/test_amend_tag_on_imported_content.html diff --git a/poleno/utils/templates/utils/tests/amendtemplatetagtest/test_amend_tag_on_imported_content.html b/poleno/utils/templates/utils/tests/amendtemplatetagtest/test_amend_tag_on_imported_content.html new file mode 100644 index 000000000..04fe746f5 --- /dev/null +++ b/poleno/utils/templates/utils/tests/amendtemplatetagtest/test_amend_tag_on_imported_content.html @@ -0,0 +1,9 @@ +{% load prepend from poleno.amend %} + + + +{% prepend path=".//ul" %}
  • xxx
  • {% endprepend %} +{% prepend path=".//li" %}!{% endprepend %} diff --git a/poleno/utils/tests/test_templatetags.py b/poleno/utils/tests/test_templatetags.py index b1c79eab0..52aee3732 100644 --- a/poleno/utils/tests/test_templatetags.py +++ b/poleno/utils/tests/test_templatetags.py @@ -451,6 +451,26 @@ def test_set_attributes_tag(self): u'' u'') + def test_amend_tag_with_operation_tags_before_content(self): + rendered = self._render( + u'{% load amend prepend from poleno.amend %}' + u'{% amend %}' + u' {% prepend path=".//ul" %}
  • xxx
  • {% endprepend %}' + u' {% prepend path=".//li" %}!{% endprepend %}' + u' ' + u'{% endamend %}' + u'') + self.assertHTMLEqual(rendered, + u'' + u'') + def test_amend_tag_on_plain_text(self): rendered = self._render( u'{% load amend prepend append from poleno.amend %}' @@ -481,6 +501,21 @@ def test_amend_tag_on_multiple_tags(self): u'

    yyy

    ' u'') + def test_amend_tag_on_imported_content(self): + rendered = self._render( + u'{% load amend from poleno.amend %}' + u'{% amend %}' + u' {% include "utils/tests/amendtemplatetagtest/test_amend_tag_on_imported_content.html" %}' + u'{% endamend %}' + u'') + self.assertHTMLEqual(rendered, + u'' + u'') + def test_multiple_amend_tags(self): rendered = self._render( u'{% load amend prepend append from poleno.amend %}' @@ -514,6 +549,82 @@ def test_multiple_amend_tags(self): u'' u'') + def test_nested_amend_tags(self): + rendered = self._render( + u'{% load amend prepend append from poleno.amend %}' + u'{% amend %}' + u' ' + u' {% prepend path=".//ul" %}
  • xxx
  • {% endprepend %}' + u' {% prepend path=".//li" %}!{% endprepend %}' + u'{% endamend %}' + u'') + self.assertHTMLEqual(rendered, + u'' + u'') + + def test_nested_amend_tags_with_operation_tags_before_content(self): + rendered = self._render( + u'{% load amend prepend append from poleno.amend %}' + u'{% amend %}' + u' {% prepend path=".//ul" %}
  • xxx
  • {% endprepend %}' + u' {% prepend path=".//li" %}!{% endprepend %}' + u' ' + u'{% endamend %}' + u'') + self.assertHTMLEqual(rendered, + u'' + u'') + def test_without_amend_tag(self): rendered = self._render( u'{% load prepend append before after delete set_attributes from poleno.amend %}'