def test_is_connection_to_a_vcenter_call_explicit_service_instance(self): expl_mock_si = MagicMock() mock_is_connection_to_a_vcenter = MagicMock() with patch('salt.utils.vmware.is_connection_to_a_vcenter', mock_is_connection_to_a_vcenter): vsphere.test_vcenter_connection(expl_mock_si) mock_is_connection_to_a_vcenter.assert_called_once_with(expl_mock_si)
def test_is_connection_to_a_vcenter_raises_non_vmware_salt_error(self): exc = Exception('NonVMwareSaltError') with patch('salt.utils.vmware.is_connection_to_a_vcenter', MagicMock(side_effect=exc)): with self.assertRaises(Exception) as excinfo: res = vsphere.test_vcenter_connection() self.assertEqual('NonVMwareSaltError', str(excinfo.exception))
def test_output_false(self): with patch('salt.utils.vmware.is_connection_to_a_vcenter', MagicMock(return_value=False)): res = vsphere.test_vcenter_connection() self.assertEqual(res, False)
def test_is_connection_to_a_vcenter_raises_vmware_salt_error(self): exc = VMwareSaltError('VMwareSaltError') with patch('salt.utils.vmware.is_connection_to_a_vcenter', MagicMock(side_effect=exc)): res = vsphere.test_vcenter_connection() self.assertEqual(res, False)
def test_supported_proxes(self): supported_proxies = ['esxi'] for proxy_type in supported_proxies: with patch('salt.modules.vsphere.get_proxy_type', MagicMock(return_value=proxy_type)): vsphere.test_vcenter_connection()