summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/tests/test_plugin_debug.py
blob: 572f82a416187df4476cb196b9e95f1b9638c910 (plain)
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
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from ..tests import CLICommandTestMixin, ControllerTestCase


class TestPluginDebug(ControllerTestCase, CLICommandTestMixin):
    @classmethod
    def setup_server(cls):
        # pylint: disable=protected-access
        cls.setup_controllers([])

    def setUp(self):
        self.mock_kv_store()

    def test_debug_disabled(self):
        self.exec_cmd('debug', action='disable')

        self._get('/api/unexisting_controller')
        self.assertStatus(404)

        data = self.json_body()
        self.assertGreater(len(data), 0)
        self.assertNotIn('traceback', data)
        self.assertNotIn('version', data)
        self.assertIn('request_id', data)

    def test_debug_enabled(self):
        self.exec_cmd('debug', action='enable')

        self._get('/api/unexisting_controller')
        self.assertStatus(404)

        data = self.json_body()
        self.assertGreater(len(data), 0)
        self.assertIn('traceback', data)
        self.assertIn('version', data)
        self.assertIn('request_id', data)