-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for
coriolis.diagnostics.api
module
- Loading branch information
1 parent
7296019
commit 0d733ce
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |