]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/tests/test_grafana.py
1 from . import ControllerTestCase
2 from ..controllers
.grafana
import Grafana
6 class GrafanaTest(ControllerTestCase
):
10 # pylint: disable=protected-access
11 Grafana
._cp
_config
['tools.authenticate.on'] = False
12 cls
.setup_controllers([Grafana
])
17 url
='http://localhost:3000',
23 settings
['GRAFANA_API_URL'] = url
25 settings
['GRAFANA_API_USERNAME'] = user
26 if password
is not None:
27 settings
['GRAFANA_API_PASSWORD'] = password
28 mgr
.get_module_option
.side_effect
= settings
.get
31 self
.server_settings()
32 self
._get
('/api/grafana/url')
33 self
.assertStatus(200)
34 self
.assertJsonBody({'instance': 'http://localhost:3000'})
36 def test_validation(self
):
37 self
.server_settings()
38 self
._get
('/api/grafana/validation/foo')
39 self
.assertStatus(500)
41 def test_dashboards(self
):
42 self
.server_settings(url
=None)
43 self
._post
('/api/grafana/dashboards')
44 self
.assertStatus(500)
45 self
.server_settings(user
=None)
46 self
._post
('/api/grafana/dashboards')
47 self
.assertStatus(500)
48 self
.server_settings(password
=None)
49 self
._post
('/api/grafana/dashboards')
50 self
.assertStatus(500)