Exemple #1
0
    def test_wsman_get_fail(self, mock_client_pywsman):
        namespace = amt_common._SOAP_ENVELOPE
        result_xml = test_utils.build_soap_xml([{'Fault': 'fault'}], namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.get.return_value = mock_doc
        client = amt_common.Client(**self.info)

        self.assertRaises(exception.AMTFailure, client.wsman_get, namespace)
        mock_pywsman.get.assert_called_once_with(mock.ANY, namespace)
    def test_wsman_get(self, mock_client_pywsman):
        namespace = resource_uris.CIM_AssociatedPowerManagementService
        result_xml = test_utils.build_soap_xml([{'PowerState':
                                                 '2'}],
                                               namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.get.return_value = mock_doc
        client = amt_common.Client(**self.info)

        client.wsman_get(namespace)
        mock_pywsman.get.assert_called_once_with(mock.ANY, namespace)
Exemple #3
0
    def test_wsman_invoke_fail(self, mock_client_pywsman):
        namespace = resource_uris.CIM_BootSourceSetting
        result_xml = test_utils.build_soap_xml([{
            'ReturnValue': '2'
        }], namespace)
        mock_doc = test_utils.mock_wsman_root(result_xml)
        mock_pywsman = mock_client_pywsman.Client.return_value
        mock_pywsman.invoke.return_value = mock_doc
        method = 'fake-method'
        options = mock.Mock(spec_set=[])

        client = amt_common.Client(**self.info)

        self.assertRaises(exception.AMTFailure, client.wsman_invoke, options,
                          namespace, method)
        mock_pywsman.invoke.assert_called_once_with(options, namespace, method)
 def test_wsman_invoke(self, mock_client_pywsman):
     namespace = resource_uris.CIM_BootSourceSetting
     result_xml = test_utils.build_soap_xml([{'ReturnValue':
                                              '0'}],
                                            namespace)
     mock_doc = test_utils.mock_wsman_root(result_xml)
     mock_pywsman = mock_client_pywsman.Client.return_value
     mock_pywsman.invoke.return_value = mock_doc
     method = 'ChangeBootOrder'
     options = mock.Mock(spec_set=[])
     client = amt_common.Client(**self.info)
     doc = None
     client.wsman_invoke(options, namespace, method, doc)
     mock_pywsman.invoke.assert_called_once_with(options, namespace, method)
     doc = 'fake-input'
     client.wsman_invoke(options, namespace, method, doc)
     mock_pywsman.invoke.assert_called_with(options, namespace, method, doc)