File: test_custom.py

package info (click to toggle)
python-django-debug-toolbar 1%3A6.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,052 kB
  • sloc: python: 7,555; javascript: 636; makefile: 67; sh: 16
file content (46 lines) | stat: -rw-r--r-- 1,533 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from django.test import override_settings

from debug_toolbar.panels import Panel

from ..base import IntegrationTestCase


class CustomPanel(Panel):
    def title(self):
        return "Title with special chars &\"'<>"


@override_settings(
    DEBUG=True, DEBUG_TOOLBAR_PANELS=["tests.panels.test_custom.CustomPanel"]
)
class CustomPanelTestCase(IntegrationTestCase):
    def test_escapes_panel_title(self):
        response = self.client.get("/regular/basic/")
        self.assertContains(
            response,
            """
            <li id="djdt-CustomPanel" class="djDebugPanelButton">
            <input type="checkbox" checked title="Disable for next and successive requests" data-cookie="djdtCustomPanel">
            <a class="CustomPanel" href="#" title="Title with special chars &amp;&quot;&#39;&lt;&gt;">
            Title with special chars &amp;&quot;&#39;&lt;&gt;
            </a>
            </li>
            """,
            html=True,
        )
        self.assertContains(
            response,
            """
            <div id="CustomPanel" class="djdt-panelContent djdt-hidden">
            <div class="djDebugPanelTitle">
            <h3>Title with special chars &amp;&quot;&#39;&lt;&gt;</h3>
            <button type="button" class="djDebugClose">×</button>
            </div>
            <div class="djDebugPanelContent">
            <div class="djdt-loader"></div>
            <div class="djdt-scroll"></div>
            </div>
            </div>
            """,
            html=True,
        )