def test_check_system_health_pass(self): """Validate check_system_health method.""" self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"}) firmware = NetAppESeriesFirmware() with patch(self.REQUEST_FUNC, side_effect=[(200, { "requestId": "1" }), (200, { "healthCheckRunning": True, "results": [{ "processingTimeMS": 0 }] }), (200, { "healthCheckRunning": False, "results": [{ "successful": True }] })]): firmware.check_system_health()
def test_check_system_health_fail(self): """Validate check_system_health method throws proper exceptions.""" self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"}) firmware = NetAppESeriesFirmware() with patch("time.sleep", return_value=None): with self.assertRaisesRegexp(AnsibleFailJson, "Failed to initiate health check."): with patch(self.REQUEST_FUNC, return_value=(404, Exception())): firmware.check_system_health() with self.assertRaisesRegexp( AnsibleFailJson, "Failed to retrieve health check status."): with patch(self.REQUEST_FUNC, side_effect=[(200, { "requestId": "1" }), (404, Exception())]): firmware.check_system_health() with self.assertRaisesRegexp(AnsibleFailJson, "Health check failed to complete."): with patch(self.REQUEST_FUNC, side_effect=[(200, { "requestId": "1" }), (200, { "healthCheckRunning": True, "results": [{ "processingTimeMS": 120001 }] })]): firmware.check_system_health()