|
1 | 1 | from cms.api import add_plugin |
2 | 2 | from cms.test_utils.testcases import CMSTestCase |
| 3 | +from django.template import Template, TemplateSyntaxError |
3 | 4 |
|
4 | 5 | from tests.fixtures import TestFixture |
5 | 6 |
|
@@ -69,3 +70,23 @@ def test_split_template_tag(self): |
69 | 70 | self.assertEqual(split("Mixin1|Mixin2"), ["Mixin1", "Mixin2"]) |
70 | 71 | self.assertEqual(split("hero.html"), ["hero.html"]) |
71 | 72 | self.assertEqual(split("hero.html, Mixin1, Mixin2", ", "), ["hero.html", "Mixin1", "Mixin2"]) |
| 73 | + |
| 74 | + def test_invalid_cms_component_usage_missing_required_argument(self): |
| 75 | + # The {% cms_component %} tag requires a component name. |
| 76 | + invalid_template = "{% load cms_tags %}{% cms_component %}" |
| 77 | + with self.assertRaises(TemplateSyntaxError): |
| 78 | + Template(invalid_template) |
| 79 | + |
| 80 | + def test_invalid_field_usage_invalid_argument(self): |
| 81 | + # The {% field %} tag requires valid arguments: a field name and a component instance. |
| 82 | + # Here we simulate invalid usage by providing an invalid component. |
| 83 | + invalid_template = "{% load cms_tags %}{% field 'nonexistent_field' component %}" |
| 84 | + with self.assertRaises(TemplateSyntaxError): |
| 85 | + Template(invalid_template) |
| 86 | + |
| 87 | + def test_multiple_cms_component_tags_error(self): |
| 88 | + # Assuming only one {% cms_component %} tag is allowed per template. |
| 89 | + # This should raise an error if multiple tags are used. |
| 90 | + invalid_template = "{% load cms_tags %}{% cms_component 'Hero' %}{% cms_component 'Footer' %}" |
| 91 | + with self.assertRaises(TemplateSyntaxError): |
| 92 | + Template(invalid_template) |
0 commit comments