diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/pybind/mgr/dashboard/tests/test_orchestrator.py | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/dashboard/tests/test_orchestrator.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/tests/test_orchestrator.py b/src/pybind/mgr/dashboard/tests/test_orchestrator.py new file mode 100644 index 000000000..53e32c85a --- /dev/null +++ b/src/pybind/mgr/dashboard/tests/test_orchestrator.py @@ -0,0 +1,40 @@ +import inspect +import unittest +from unittest import mock + +from orchestrator import Orchestrator as OrchestratorBase + +from ..controllers.orchestrator import Orchestrator +from ..services.orchestrator import OrchFeature +from ..tests import ControllerTestCase + + +class OrchestratorControllerTest(ControllerTestCase): + URL_STATUS = '/ui-api/orchestrator/status' + URL_INVENTORY = '/api/orchestrator/inventory' + + @classmethod + def setup_server(cls): + cls.setup_controllers([Orchestrator]) + + @mock.patch('dashboard.controllers.orchestrator.OrchClient.instance') + def test_status_get(self, instance): + status = {'available': False, 'description': ''} + + fake_client = mock.Mock() + fake_client.status.return_value = status + instance.return_value = fake_client + + self._get(self.URL_STATUS) + self.assertStatus(200) + self.assertJsonBody(status) + + +class TestOrchestrator(unittest.TestCase): + def test_features_has_corresponding_methods(self): + defined_methods = [v for k, v in inspect.getmembers( + OrchFeature, lambda m: not inspect.isroutine(m)) if not k.startswith('_')] + orchestrator_methods = [k for k, v in inspect.getmembers( + OrchestratorBase, inspect.isroutine)] + for method in defined_methods: + self.assertIn(method, orchestrator_methods) |