~ubuntu-branches/ubuntu/vivid/python-oslo.vmware/vivid

« back to all changes in this revision

Viewing changes to tests/test_vim_util.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2015-04-10 11:46:52 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20150410114652-8htuh3zsmgtmhxb9
Tags: 0.11.1-0ubuntu1
New upstream release (LP: #1444594)

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
        self.assertTrue(res is retrieve_result.objects)
254
254
        cancel_retrieval.assert_called_once_with(vim, retrieve_result)
255
255
 
256
 
    @mock.patch('oslo_vmware.vim_util.get_object_properties')
257
 
    def test_get_object_properties_dict_empty(self, mock_obj_prop):
258
 
        mock_obj_prop.return_value = None
259
 
        vim = mock.Mock()
260
 
        moref = mock.Mock()
261
 
        res = vim_util.get_object_properties_dict(vim, moref, None)
262
 
        self.assertEqual({}, res)
263
 
 
264
 
    @mock.patch('oslo_vmware.vim_util.get_object_properties')
265
 
    def test_get_object_properties_dict(self, mock_obj_prop):
266
 
        expected_prop_dict = {'name': 'vm01'}
267
 
        mock_obj_content = mock.Mock()
268
 
        prop = mock.Mock()
269
 
        prop.name = "name"
270
 
        prop.val = "vm01"
271
 
        mock_obj_content.propSet = [prop]
272
 
        del mock_obj_content.missingSet
273
 
        mock_obj_prop.return_value = [mock_obj_content]
274
 
        vim = mock.Mock()
275
 
        moref = mock.Mock()
276
 
        res = vim_util.get_object_properties_dict(vim, moref, None)
277
 
        self.assertEqual(expected_prop_dict, res)
278
 
 
279
 
    @mock.patch('oslo_vmware.vim_util.get_object_properties')
280
 
    def test_get_object_properties_dict_missing(self, mock_obj_prop):
281
 
        mock_obj_content = mock.Mock()
282
 
        missing_prop = mock.Mock()
283
 
        missing_prop.path = "name"
284
 
        missing_prop.fault = mock.Mock()
285
 
        mock_obj_content.missingSet = [missing_prop]
286
 
        del mock_obj_content.propSet
287
 
        mock_obj_prop.return_value = [mock_obj_content]
288
 
        vim = mock.Mock()
289
 
        moref = mock.Mock()
290
 
        res = vim_util.get_object_properties_dict(vim, moref, None)
291
 
        self.assertEqual({}, res)
292
 
 
293
256
    @mock.patch('oslo_vmware.vim_util._get_token')
294
257
    def test_cancel_retrieval(self, get_token):
295
258
        token = mock.Mock()