File: test_settings.py

package info (click to toggle)
python-django-debug-toolbar 1%3A6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,116 kB
  • sloc: python: 7,869; javascript: 636; makefile: 67; sh: 16
file content (56 lines) | stat: -rw-r--r-- 2,020 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
from django.test import RequestFactory, override_settings

from debug_toolbar.panels.settings import SettingsPanel

from ..base import BaseTestCase, IntegrationTestCase

rf = RequestFactory()


class SettingsPanelTestCase(BaseTestCase):
    panel_id = SettingsPanel.panel_id

    def test_panel_recording(self):
        self.request = rf.post("/", data={"foo": "bar"})
        response = self.panel.process_request(self.request)
        self.panel.generate_stats(self.request, response)

        settings = self.panel.get_stats()["settings"]
        self.assertEqual(settings["USE_THOUSAND_SEPARATOR"], "False")
        self.assertEqual(settings["ABSOLUTE_URL_OVERRIDES"], "{}")
        self.assertEqual(settings["EMAIL_HOST"], "'localhost'")
        self.assertEqual(settings["EMAIL_PORT"], "25")


@override_settings(DEBUG=True)
class SettingsIntegrationTestCase(IntegrationTestCase):
    def test_panel_title(self):
        response = self.client.get("/regular/basic/")
        # The settings module is None due to using Django's UserSettingsHolder
        # in tests.
        self.assertContains(
            response,
            """
            <li id="djdt-SettingsPanel" class="djDebugPanelButton">
            <input type="checkbox" checked title="Disable for next and successive requests" data-cookie="djdtSettingsPanel">
            <a class="SettingsPanel" href="#" title="Settings from None">Settings</a>
            </li>
            """,
            html=True,
        )
        self.assertContains(
            response,
            """
            <div id="SettingsPanel" class="djdt-panelContent djdt-hidden">
            <div class="djDebugPanelTitle">
            <h3>Settings from None</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,
        )