From fa594ff9269a2fda1ed0977e1e0c6e41447a136d Mon Sep 17 00:00:00 2001 From: Sabari Kumar Murugesan Date: Tue, 3 Mar 2015 17:12:31 -0800 Subject: [PATCH] Move missing tests to new oslo_vmware location commits a95c0ae05f91c81de061c6e1460189259f7717fe and 3356e2e147043a4e57117a5977932232d3412c52 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 --- .../tests}/network/__init__.py | 0 .../tests}/network/nsx/__init__.py | 0 .../tests}/network/nsx/nsxv/__init__.py | 0 .../tests}/network/nsx/nsxv/test_nsxv_api.py | 0 .../network/nsx/nsxv/test_nsxv_api_helper.py | 0 .../nsx/nsxv/test_nsxv_loadbalancer.py | 0 oslo_vmware/tests/objects/test_datastore.py | 15 ++++++++ oslo_vmware/tests/test_vim_util.py | 37 +++++++++++++++++++ tests/objects/test_datastore.py | 15 -------- tests/test_vim_util.py | 37 ------------------- 10 files changed, 52 insertions(+), 52 deletions(-) rename {tests => oslo_vmware/tests}/network/__init__.py (100%) rename {tests => oslo_vmware/tests}/network/nsx/__init__.py (100%) rename {tests => oslo_vmware/tests}/network/nsx/nsxv/__init__.py (100%) rename {tests => oslo_vmware/tests}/network/nsx/nsxv/test_nsxv_api.py (100%) rename {tests => oslo_vmware/tests}/network/nsx/nsxv/test_nsxv_api_helper.py (100%) rename {tests => oslo_vmware/tests}/network/nsx/nsxv/test_nsxv_loadbalancer.py (100%) diff --git a/tests/network/__init__.py b/oslo_vmware/tests/network/__init__.py similarity index 100% rename from tests/network/__init__.py rename to oslo_vmware/tests/network/__init__.py diff --git a/tests/network/nsx/__init__.py b/oslo_vmware/tests/network/nsx/__init__.py similarity index 100% rename from tests/network/nsx/__init__.py rename to oslo_vmware/tests/network/nsx/__init__.py diff --git a/tests/network/nsx/nsxv/__init__.py b/oslo_vmware/tests/network/nsx/nsxv/__init__.py similarity index 100% rename from tests/network/nsx/nsxv/__init__.py rename to oslo_vmware/tests/network/nsx/nsxv/__init__.py diff --git a/tests/network/nsx/nsxv/test_nsxv_api.py b/oslo_vmware/tests/network/nsx/nsxv/test_nsxv_api.py similarity index 100% rename from tests/network/nsx/nsxv/test_nsxv_api.py rename to oslo_vmware/tests/network/nsx/nsxv/test_nsxv_api.py diff --git a/tests/network/nsx/nsxv/test_nsxv_api_helper.py b/oslo_vmware/tests/network/nsx/nsxv/test_nsxv_api_helper.py similarity index 100% rename from tests/network/nsx/nsxv/test_nsxv_api_helper.py rename to oslo_vmware/tests/network/nsx/nsxv/test_nsxv_api_helper.py diff --git a/tests/network/nsx/nsxv/test_nsxv_loadbalancer.py b/oslo_vmware/tests/network/nsx/nsxv/test_nsxv_loadbalancer.py similarity index 100% rename from tests/network/nsx/nsxv/test_nsxv_loadbalancer.py rename to oslo_vmware/tests/network/nsx/nsxv/test_nsxv_loadbalancer.py diff --git a/oslo_vmware/tests/objects/test_datastore.py b/oslo_vmware/tests/objects/test_datastore.py index cb36ecc4..801f24b2 100644 --- a/oslo_vmware/tests/objects/test_datastore.py +++ b/oslo_vmware/tests/objects/test_datastore.py @@ -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) diff --git a/oslo_vmware/tests/test_vim_util.py b/oslo_vmware/tests/test_vim_util.py index a306d009..6548c5f5 100644 --- a/oslo_vmware/tests/test_vim_util.py +++ b/oslo_vmware/tests/test_vim_util.py @@ -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() diff --git a/tests/objects/test_datastore.py b/tests/objects/test_datastore.py index aa88a22d..2d66ccff 100644 --- a/tests/objects/test_datastore.py +++ b/tests/objects/test_datastore.py @@ -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) diff --git a/tests/test_vim_util.py b/tests/test_vim_util.py index b19cd48e..44b65267 100644 --- a/tests/test_vim_util.py +++ b/tests/test_vim_util.py @@ -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()