"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/utils/test_vmware.py" between
salt-3002.1.tar.gz and salt-3002.2.tar.gz

About: SaltStack is a systems management software for data center automation, cloud orchestration, server provisioning, configuration management and more. Community version.

test_vmware.py  (salt-3002.1):test_vmware.py  (salt-3002.2)
skipping to change at line 1995 skipping to change at line 1995
"fake_password", "fake_password",
"fake_protocol", "fake_protocol",
1, 1,
"fake_mechanism", "fake_mechanism",
"fake_principal", "fake_principal",
"fake_domain", "fake_domain",
) )
def test_cached_service_instance_different_host(self): def test_cached_service_instance_different_host(self):
mock_si = MagicMock() mock_si = MagicMock()
mock_si_stub = MagicMock()
mock_disconnect = MagicMock() mock_disconnect = MagicMock()
mock_get_si = MagicMock(return_value=mock_si) mock_get_si = MagicMock(return_value=mock_si)
mock_getstub = MagicMock() mock_getstub = MagicMock()
with patch("salt.utils.vmware.GetSi", mock_get_si): with patch("salt.utils.vmware.GetSi", mock_get_si):
with patch("salt.utils.vmware.GetStub", mock_getstub): with patch("salt.utils.vmware.GetStub", mock_getstub):
with patch("salt.utils.vmware.Disconnect", mock_disconnect): with patch("salt.utils.vmware.Disconnect", mock_disconnect):
salt.utils.vmware.get_service_instance( salt.utils.vmware.get_service_instance(
host="fake_host", host="fake_host",
username="fake_username", username="fake_username",
password="fake_password", password="fake_password",
skipping to change at line 2063 skipping to change at line 2062
protocol="fake_protocol", protocol="fake_protocol",
port=1, port=1,
mechanism="fake_mechanism", mechanism="fake_mechanism",
principal="fake_principal", principal="fake_principal",
domain="fake_domain", domain="fake_domain",
) )
self.assertEqual(mock_si_current_time.call_count, 1) self.assertEqual(mock_si_current_time.call_count, 1)
self.assertEqual(mock_disconnect.call_count, 1) self.assertEqual(mock_disconnect.call_count, 1)
self.assertEqual(mock_get_si.call_count, 2) self.assertEqual(mock_get_si.call_count, 2)
def test_cached_unauthenticated_service_instance(self):
mock_si_current_time = MagicMock(side_effect=vim.fault.NotAuthenticated)
mock_si = MagicMock()
mock_get_si = MagicMock(return_value=mock_si)
mock_getsi = MagicMock(return_value=mock_si)
mock_si.CurrentTime = mock_si_current_time
mock_disconnect = MagicMock()
with patch("salt.utils.vmware.GetSi", mock_getsi):
with patch("salt.utils.vmware._get_service_instance", mock_get_si):
with patch("salt.utils.vmware.Disconnect", mock_disconnect):
salt.utils.vmware.get_service_instance(
host="fake_host",
username="fake_username",
password="fake_password",
protocol="fake_protocol",
port=1,
mechanism="fake_mechanism",
principal="fake_principal",
domain="fake_domain",
)
self.assertEqual(mock_si_current_time.call_count, 1)
self.assertEqual(mock_disconnect.call_count, 1)
self.assertEqual(mock_get_si.call_count, 1)
def test_current_time_raise_no_permission(self): def test_current_time_raise_no_permission(self):
exc = vim.fault.NoPermission() exc = vim.fault.NoPermission()
exc.privilegeId = "Fake privilege" exc.privilegeId = "Fake privilege"
with patch( with patch(
"salt.utils.vmware._get_service_instance", "salt.utils.vmware._get_service_instance",
MagicMock(return_value=MagicMock(CurrentTime=MagicMock(side_effect=e xc))), MagicMock(return_value=MagicMock(CurrentTime=MagicMock(side_effect=e xc))),
): ):
with self.assertRaises(VMwareApiError) as excinfo: with self.assertRaises(VMwareApiError) as excinfo:
salt.utils.vmware.get_service_instance( salt.utils.vmware.get_service_instance(
host="fake_host", host="fake_host",
 End of changes. 2 change blocks. 
1 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)