]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/tests/test_daemon.py
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / tests / test_daemon.py
CommitLineData
20effc67
TL
1# -*- coding: utf-8 -*-
2
3from ..controllers._version import APIVersion
4from ..controllers.daemon import Daemon
5from ..tests import ControllerTestCase, patch_orch
6
7
8class DaemonTest(ControllerTestCase):
9
10 URL_DAEMON = '/api/daemon'
11
12 @classmethod
13 def setup_server(cls):
14 cls.setup_controllers([Daemon])
15
16 def test_daemon_action(self):
17 msg = "Scheduled to stop crash.b78cd1164a1b on host 'hostname'"
18
19 with patch_orch(True) as fake_client:
20 fake_client.daemons.action.return_value = msg
21 payload = {
22 'action': 'restart',
23 'container_image': None
24 }
25 self._put(f'{self.URL_DAEMON}/crash.b78cd1164a1b', payload, version=APIVersion(0, 1))
26 self.assertJsonBody(msg)
27 self.assertStatus(200)
28
29 def test_daemon_invalid_action(self):
30 payload = {
31 'action': 'invalid',
32 'container_image': None
33 }
34 with patch_orch(True):
35 self._put(f'{self.URL_DAEMON}/crash.b78cd1164a1b', payload, version=APIVersion(0, 1))
36 self.assertJsonBody({
37 'detail': 'Daemon action "invalid" is either not valid or not supported.',
38 'code': 'invalid_daemon_action',
39 'component': None
40 })
41 self.assertStatus(400)
aee94f69
TL
42
43 def test_daemon_list(self):
44 with patch_orch(True):
45 self._get(f'{self.URL_DAEMON}')
46 self.assertStatus(200)