Skip to content

Commit

Permalink
Add tests for coriolis.conductor.diagnostics.api module
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristi1324 committed Mar 29, 2024
1 parent 7296019 commit 764a0af
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion coriolis/diagnostics/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from coriolis import utils
# Copyright 2024 Cloudbase Solutions Srl
# All Rights Reserved.

from coriolis.conductor.rpc import client as conductor_rpc
from coriolis.replica_cron.rpc import client as cron_rpc
from coriolis import utils
from coriolis.worker.rpc import client as worker_rpc


Expand Down
Empty file.
40 changes: 40 additions & 0 deletions coriolis/tests/diagnostics/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 Cloudbase Solutions Srl
# All Rights Reserved.

from unittest import mock

from coriolis.diagnostics import api
from coriolis.tests import test_base
from coriolis import utils


class DiagnosticsAPITestCase(test_base.CoriolisBaseTestCase):
"""Test suite for the Coriolis Diagnostics API."""

def setUp(self):
super(DiagnosticsAPITestCase, self).setUp()
self.diagnostics_api = api.API()
self.diagnostics_api._conductor_cli = mock.Mock()

@mock.patch.object(utils, "get_diagnostics_info")
def test_get(
self,
mock_get_diagnostics_info
):
(self.diagnostics_api._conductor_cli.get_all_diagnostics.
return_value) = [mock.sentinel.all_diag]
mock_get_diagnostics_info.return_value = mock.sentinel.diag_info
expected_result = [
mock.sentinel.all_diag,
mock.sentinel.diag_info
]

result = self.diagnostics_api.get(mock.sentinel.context)

self.assertEqual(
expected_result,
result
)
(self.diagnostics_api._conductor_cli.get_all_diagnostics.
assert_called_once_with)(mock.sentinel.context)
mock_get_diagnostics_info.assert_called_once()

0 comments on commit 764a0af

Please sign in to comment.