diff options
Diffstat (limited to 'dracclient/tests/test_lifecycle_controller.py')
-rw-r--r-- | dracclient/tests/test_lifecycle_controller.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/dracclient/tests/test_lifecycle_controller.py b/dracclient/tests/test_lifecycle_controller.py index 8498e90..ad13431 100644 --- a/dracclient/tests/test_lifecycle_controller.py +++ b/dracclient/tests/test_lifecycle_controller.py | |||
@@ -11,9 +11,11 @@ | |||
11 | # License for the specific language governing permissions and limitations | 11 | # License for the specific language governing permissions and limitations |
12 | # under the License. | 12 | # under the License. |
13 | 13 | ||
14 | import mock | ||
14 | import requests_mock | 15 | import requests_mock |
15 | 16 | ||
16 | import dracclient.client | 17 | import dracclient.client |
18 | from dracclient import exceptions | ||
17 | from dracclient.resources import lifecycle_controller | 19 | from dracclient.resources import lifecycle_controller |
18 | from dracclient.resources import uris | 20 | from dracclient.resources import uris |
19 | from dracclient.tests import base | 21 | from dracclient.tests import base |
@@ -84,3 +86,47 @@ class ClientLCConfigurationTestCase(base.BaseTest): | |||
84 | lifecycle_settings) | 86 | lifecycle_settings) |
85 | self.assertEqual(expected_string_attr, | 87 | self.assertEqual(expected_string_attr, |
86 | lifecycle_settings['LifecycleController.Embedded.1#LCAttributes.1#SystemID']) # noqa | 88 | lifecycle_settings['LifecycleController.Embedded.1#LCAttributes.1#SystemID']) # noqa |
89 | |||
90 | @requests_mock.Mocker() | ||
91 | def test_is_idrac_ready_ready(self, mock_requests): | ||
92 | expected_text = test_utils.LifecycleControllerInvocations[ | ||
93 | uris.DCIM_LCService]['GetRemoteServicesAPIStatus']['is_ready'] | ||
94 | mock_requests.post('https://1.2.3.4:443/wsman', | ||
95 | text=expected_text) | ||
96 | |||
97 | self.assertTrue(self.drac_client.is_idrac_ready()) | ||
98 | |||
99 | @requests_mock.Mocker() | ||
100 | def test_is_idrac_ready_not_ready(self, mock_requests): | ||
101 | expected_text = test_utils.LifecycleControllerInvocations[ | ||
102 | uris.DCIM_LCService]['GetRemoteServicesAPIStatus']['is_not_ready'] | ||
103 | mock_requests.post('https://1.2.3.4:443/wsman', | ||
104 | text=expected_text) | ||
105 | |||
106 | self.assertFalse(self.drac_client.is_idrac_ready()) | ||
107 | |||
108 | @requests_mock.Mocker() | ||
109 | def test_wait_until_idrac_is_ready_ready(self, mock_requests): | ||
110 | expected_text = test_utils.LifecycleControllerInvocations[ | ||
111 | uris.DCIM_LCService]['GetRemoteServicesAPIStatus']['is_ready'] | ||
112 | mock_requests.post('https://1.2.3.4:443/wsman', | ||
113 | text=expected_text) | ||
114 | |||
115 | try: | ||
116 | self.drac_client.wait_until_idrac_is_ready() | ||
117 | except exceptions.DRACOperationFailed: | ||
118 | self.fail('wait_until_idrac_is_ready() timed out when it should ' | ||
119 | 'not have!') | ||
120 | |||
121 | @requests_mock.Mocker() | ||
122 | @mock.patch('time.sleep', autospec=True) | ||
123 | def test_wait_until_idrac_is_ready_timeout(self, | ||
124 | mock_requests, | ||
125 | mock_ts): | ||
126 | expected_text = test_utils.LifecycleControllerInvocations[ | ||
127 | uris.DCIM_LCService]['GetRemoteServicesAPIStatus']['is_not_ready'] | ||
128 | mock_requests.post('https://1.2.3.4:443/wsman', | ||
129 | text=expected_text) | ||
130 | |||
131 | self.assertRaises(exceptions.DRACOperationFailed, | ||
132 | self.drac_client.wait_until_idrac_is_ready) | ||