def test_get_mors_with_properties(self): vmware.get_network_folder(self.mock_dc_ref) self.mock_get_mors.assert_called_once_with( self.mock_si, vim.Folder, container_ref=self.mock_dc_ref, property_list=['name'], traversal_spec=self.mock_traversal_spec)
def test_get_no_network_folder(self): with patch('salt.utils.vmware.get_mors_with_properties', MagicMock(return_value=[])): with self.assertRaises(VMwareObjectRetrievalError) as excinfo: vmware.get_network_folder(self.mock_dc_ref) self.assertEqual( excinfo.exception.strerror, 'Network folder in datacenter \'fake_dc\' wasn\'t ' 'retrieved')
def test_traversal_spec(self): mock_traversal_spec = MagicMock(return_value='traversal_spec') with patch( 'salt.utils.vmware.vmodl.query.PropertyCollector.TraversalSpec', mock_traversal_spec): vmware.get_network_folder(self.mock_dc_ref) mock_traversal_spec.assert_called_once_with(path='networkFolder', skip=False, type=vim.Datacenter)
def test_get_network_folder(self): ret = vmware.get_network_folder(self.mock_dc_ref) self.assertEqual(ret, self.mock_entries[0]['object'])
def test_get_managed_object_name_call(self): mock_get_managed_object_name = MagicMock() with patch('salt.utils.vmware.get_managed_object_name', mock_get_managed_object_name): vmware.get_network_folder(self.mock_dc_ref) mock_get_managed_object_name.assert_called_once_with(self.mock_dc_ref)