1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00
django/tests/admin_inlines/test_templates.py
Thomas Grainger d638cdc42a Fixed #25165 -- Removed inline JavaScript from the admin.
This allows setting a Content-Security-Policy HTTP header
(refs #15727).

Special thanks to blighj, the original author of this patch.
2015-12-05 15:51:57 -05:00

26 lines
980 B
Python

from __future__ import unicode_literals
import json
from django.template.loader import render_to_string
from django.test import SimpleTestCase
class TestTemplates(SimpleTestCase):
def test_javascript_escaping(self):
context = {
'inline_admin_formset': {
'inline_formset_data': json.dumps({
'formset': {'prefix': 'my-prefix'},
'opts': {'verbose_name': 'verbose name\\'},
}),
},
}
output = render_to_string('admin/edit_inline/stacked.html', context)
self.assertIn('"prefix": "my-prefix"', output)
self.assertIn('"verbose_name": "verbose name\\\\"', output)
output = render_to_string('admin/edit_inline/tabular.html', context)
self.assertIn('"prefix": "my-prefix"', output)
self.assertIn('"verbose_name": "verbose name\\\\"', output)