Move missing tests to new oslo_vmware location

commits a95c0ae05f
and 3356e2e147 added new tests meant for
oslo_vmware to the old tests location. Going forward, the old tests
location can be removed and we do not want to lose these new tests.

This patch moves the missing tests to the new location. One should make
sure tests for new code are added to oslo_vmware/tests location.

Change-Id: I67b3954dd6cd8e64357ceb78a990a2690b8c9c8e
This commit is contained in:
Sabari Kumar Murugesan 2015-03-03 17:12:31 -08:00 committed by Sabari
parent 4f3bdda1e8
commit fa594ff926
10 changed files with 52 additions and 52 deletions

View File

@ -382,3 +382,18 @@ class DatastoreURLTestCase(base.TestCase):
ticket = ds_url.get_transfer_ticket(session, 'PUT')
self.assertEqual('%s="%s"' % (constants.CGI_COOKIE_KEY, 'fake_id'),
ticket)
def test_get_datastore_by_ref(self):
session = mock.Mock()
ds_ref = mock.Mock()
expected_props = {'summary.name': 'datastore1',
'summary.type': 'NFS',
'summary.freeSpace': 1000,
'summary.capacity': 2000}
session.invoke_api = mock.Mock()
session.invoke_api.return_value = expected_props
ds_obj = datastore.get_datastore_by_ref(session, ds_ref)
self.assertEqual(expected_props['summary.name'], ds_obj.name)
self.assertEqual(expected_props['summary.type'], ds_obj.type)
self.assertEqual(expected_props['summary.freeSpace'], ds_obj.freespace)
self.assertEqual(expected_props['summary.capacity'], ds_obj.capacity)

View File

@ -257,6 +257,43 @@ class VimUtilTest(base.TestCase):
retrieve_result = object()
self.assertFalse(vim_util._get_token(retrieve_result))
@mock.patch('oslo_vmware.vim_util.get_object_properties')
def test_get_object_properties_dict_empty(self, mock_obj_prop):
mock_obj_prop.return_value = None
vim = mock.Mock()
moref = mock.Mock()
res = vim_util.get_object_properties_dict(vim, moref, None)
self.assertEqual({}, res)
@mock.patch('oslo_vmware.vim_util.get_object_properties')
def test_get_object_properties_dict(self, mock_obj_prop):
expected_prop_dict = {'name': 'vm01'}
mock_obj_content = mock.Mock()
prop = mock.Mock()
prop.name = "name"
prop.val = "vm01"
mock_obj_content.propSet = [prop]
del mock_obj_content.missingSet
mock_obj_prop.return_value = [mock_obj_content]
vim = mock.Mock()
moref = mock.Mock()
res = vim_util.get_object_properties_dict(vim, moref, None)
self.assertEqual(expected_prop_dict, res)
@mock.patch('oslo_vmware.vim_util.get_object_properties')
def test_get_object_properties_dict_missing(self, mock_obj_prop):
mock_obj_content = mock.Mock()
missing_prop = mock.Mock()
missing_prop.path = "name"
missing_prop.fault = mock.Mock()
mock_obj_content.missingSet = [missing_prop]
del mock_obj_content.propSet
mock_obj_prop.return_value = [mock_obj_content]
vim = mock.Mock()
moref = mock.Mock()
res = vim_util.get_object_properties_dict(vim, moref, None)
self.assertEqual({}, res)
@mock.patch('oslo_vmware.vim_util._get_token')
def test_cancel_retrieval(self, get_token):
token = mock.Mock()

View File

@ -383,18 +383,3 @@ class DatastoreURLTestCase(base.TestCase):
ticket = ds_url.get_transfer_ticket(session, 'PUT')
self.assertEqual('%s="%s"' % (constants.CGI_COOKIE_KEY, 'fake_id'),
ticket)
def test_get_datastore_by_ref(self):
session = mock.Mock()
ds_ref = mock.Mock()
expected_props = {'summary.name': 'datastore1',
'summary.type': 'NFS',
'summary.freeSpace': 1000,
'summary.capacity': 2000}
session.invoke_api = mock.Mock()
session.invoke_api.return_value = expected_props
ds_obj = datastore.get_datastore_by_ref(session, ds_ref)
self.assertEqual(expected_props['summary.name'], ds_obj.name)
self.assertEqual(expected_props['summary.type'], ds_obj.type)
self.assertEqual(expected_props['summary.freeSpace'], ds_obj.freespace)
self.assertEqual(expected_props['summary.capacity'], ds_obj.capacity)

View File

@ -253,43 +253,6 @@ class VimUtilTest(base.TestCase):
self.assertTrue(res is retrieve_result.objects)
cancel_retrieval.assert_called_once_with(vim, retrieve_result)
@mock.patch('oslo_vmware.vim_util.get_object_properties')
def test_get_object_properties_dict_empty(self, mock_obj_prop):
mock_obj_prop.return_value = None
vim = mock.Mock()
moref = mock.Mock()
res = vim_util.get_object_properties_dict(vim, moref, None)
self.assertEqual({}, res)
@mock.patch('oslo_vmware.vim_util.get_object_properties')
def test_get_object_properties_dict(self, mock_obj_prop):
expected_prop_dict = {'name': 'vm01'}
mock_obj_content = mock.Mock()
prop = mock.Mock()
prop.name = "name"
prop.val = "vm01"
mock_obj_content.propSet = [prop]
del mock_obj_content.missingSet
mock_obj_prop.return_value = [mock_obj_content]
vim = mock.Mock()
moref = mock.Mock()
res = vim_util.get_object_properties_dict(vim, moref, None)
self.assertEqual(expected_prop_dict, res)
@mock.patch('oslo_vmware.vim_util.get_object_properties')
def test_get_object_properties_dict_missing(self, mock_obj_prop):
mock_obj_content = mock.Mock()
missing_prop = mock.Mock()
missing_prop.path = "name"
missing_prop.fault = mock.Mock()
mock_obj_content.missingSet = [missing_prop]
del mock_obj_content.propSet
mock_obj_prop.return_value = [mock_obj_content]
vim = mock.Mock()
moref = mock.Mock()
res = vim_util.get_object_properties_dict(vim, moref, None)
self.assertEqual({}, res)
@mock.patch('oslo_vmware.vim_util._get_token')
def test_cancel_retrieval(self, get_token):
token = mock.Mock()