Drop explicit suds dependency

we should just use what oslo.vmware requires. Transitive
dependency should be enough for Nova.

Remove a few imports in a test case to pass the nova
policy of "if any explicit import then need an entry
in requirements".

Also remove tests relating to suds as oslo.vmware uses
suds and any of these tests should be there instead.

Co-Authored-By: Victor Stinner <vstinner@redhat.com>
Change-Id: I28f29d3e5745c21b99dc0cf9eb0cfe4f95dffd17
This commit is contained in:
Davanum Srinivas
2015-05-08 16:49:22 -04:00
committed by Victor Stinner
parent 6c8adefb9d
commit d47a8355d1
6 changed files with 1 additions and 115 deletions
-3
View File
@@ -274,9 +274,6 @@ class HackingTestCase(test.NoDBTestCase):
checks.validate_log_translations(ok, ok, 'f'))))
def test_no_mutable_default_args(self):
self.assertEqual(1, len(list(checks.no_mutable_default_args(
" def fake_suds_context(calls={}):"))))
self.assertEqual(1, len(list(checks.no_mutable_default_args(
"def get_info_from_bdm(virt_type, bdm, mapping=[])"))))
-40
View File
@@ -17,9 +17,6 @@
Stubouts for the test suite
"""
import contextlib
import mock
from oslo_vmware import exceptions as vexc
from nova.tests.unit.virt.vmwareapi import fake
@@ -77,40 +74,3 @@ def set_stubs(stubs):
stubs.Set(driver.VMwareAPISession, "vim", fake_vim_prop)
stubs.Set(driver.VMwareAPISession, "_is_vim_object",
fake_is_vim_object)
def fake_suds_context(calls=None):
"""Generate a suds client which automatically mocks all SOAP method calls.
Calls are stored in <calls>, indexed by the name of the call. If you need
to mock the behaviour of specific API calls you can pre-populate <calls>
with appropriate Mock objects.
"""
calls = calls or {}
class fake_factory(object):
def create(self, name):
return mock.NonCallableMagicMock(name=name)
class fake_service(object):
def __getattr__(self, attr_name):
if attr_name in calls:
return calls[attr_name]
mock_call = mock.MagicMock(name=attr_name)
calls[attr_name] = mock_call
return mock_call
class fake_client(object):
def __init__(self, wdsl_url, **kwargs):
self.service = fake_service()
self.factory = fake_factory()
return contextlib.nested(
mock.patch('suds.client.Client', fake_client),
# As we're not connecting to a real host there's no need to wait
# between retries
mock.patch.object(driver, 'TIME_BETWEEN_API_CALL_RETRIES', 0)
)
@@ -21,7 +21,6 @@ Test suite for VMwareAPI.
import collections
import contextlib
import copy
import datetime
from eventlet import greenthread
@@ -34,9 +33,7 @@ from oslo_utils import uuidutils
from oslo_vmware import exceptions as vexc
from oslo_vmware.objects import datastore as ds_obj
from oslo_vmware import pbm
from oslo_vmware import vim
from oslo_vmware import vim_util as oslo_vim_util
import suds
from nova import block_device
from nova.compute import api as compute_api
@@ -86,33 +83,6 @@ class fake_service_content(object):
self.ServiceContent.fake = 'fake'
class VMwareSudsTest(test.NoDBTestCase):
def setUp(self):
super(VMwareSudsTest, self).setUp()
def new_client_init(self, url, **kwargs):
return
mock.patch.object(suds.client.Client,
'__init__', new=new_client_init).start()
self.vim = self._vim_create()
self.addCleanup(mock.patch.stopall)
def _mock_getattr(self, attr_name):
self.assertEqual("RetrieveServiceContent", attr_name)
return lambda obj, **kwargs: fake_service_content()
def _vim_create(self):
with mock.patch.object(vim.Vim, '__getattr__', self._mock_getattr):
return vim.Vim()
def test_exception_with_deepcopy(self):
self.assertIsNotNone(self.vim)
self.assertRaises(vexc.VimException,
copy.deepcopy, self.vim)
def _fake_create_session(inst):
session = vmwareapi_fake.DataObject()
session.key = 'fake_key'
@@ -12,15 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import collections
import fixtures
import mock
from nova import test
from nova.tests.unit.virt.vmwareapi import fake
from nova.tests.unit.virt.vmwareapi import stubs
from nova.virt.vmwareapi import driver
from nova.virt.vmwareapi import vim_util
@@ -63,41 +59,6 @@ class VMwareVIMUtilTestCase(test.NoDBTestCase):
'fake-type', 'fake-property')
self.assertIsNone(res)
def test_get_dynamic_properties_with_token(self):
ObjectContent = collections.namedtuple('ObjectContent', ['propSet'])
DynamicProperty = collections.namedtuple('Property', ['name', 'val'])
# Add a token to our results, indicating that more are available
result = fake.FakeRetrieveResult(token='fake_token')
# We expect these properties to be returned
result.add_object(ObjectContent(propSet=[
DynamicProperty(name='name1', val='value1'),
DynamicProperty(name='name2', val='value2')
]))
# These properties should be ignored
result.add_object(ObjectContent(propSet=[
DynamicProperty(name='name3', val='value3')
]))
retrievePropertiesEx = mock.MagicMock(name='RetrievePropertiesEx')
retrievePropertiesEx.return_value = result
calls = {'RetrievePropertiesEx': retrievePropertiesEx}
with stubs.fake_suds_context(calls):
session = driver.VMwareAPISession(host_ip='localhost')
service_content = session.vim.service_content
props = session._call_method(vim_util, "get_dynamic_properties",
service_content.propertyCollector,
'fake_type', None)
self.assertEqual(props, {
'name1': 'value1',
'name2': 'value2'
})
@mock.patch.object(vim_util, 'get_object_properties', return_value=None)
def test_get_dynamic_properties_no_objects(self, mock_get_object_props):
res = vim_util.get_dynamic_properties('fake-vim', 'fake-obj',
+1 -2
View File
@@ -21,7 +21,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_vmware import vim_util as vutil
import six
import suds
from nova.i18n import _LW
@@ -47,7 +46,7 @@ def object_to_dict(obj, list_depth=1):
are converted.
"""
d = {}
for k, v in six.iteritems(suds.sudsobject.asdict(obj)):
for k, v in six.iteritems(dict(obj)):
if hasattr(v, '__keylist__'):
d[k] = object_to_dict(v, list_depth=list_depth)
elif isinstance(v, list):
-1
View File
@@ -22,5 +22,4 @@ testtools>=0.9.36,!=1.2.0
tempest-lib>=0.5.0
# vmwareapi driver specific dependencies
suds>=0.4
oslo.vmware>=0.11.1 # Apache-2.0