Merge "Soap Plugin: Initial client and tests"
This commit is contained in:
commit
e5c501e23a
16
plugins/soap/cafe/__init__.py
Normal file
16
plugins/soap/cafe/__init__.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
__import__('pkg_resources').declare_namespace(__name__)
|
15
plugins/soap/cafe/engine/__init__.py
Normal file
15
plugins/soap/cafe/engine/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
15
plugins/soap/cafe/engine/soap/__init__.py
Normal file
15
plugins/soap/cafe/engine/soap/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
60
plugins/soap/cafe/engine/soap/client.py
Normal file
60
plugins/soap/cafe/engine/soap/client.py
Normal file
@ -0,0 +1,60 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import suds
|
||||
import suds.xsd.doctor as suds_doctor
|
||||
|
||||
from cafe.engine.clients.base import BaseClient
|
||||
|
||||
|
||||
class BaseSoapClient(BaseClient):
|
||||
"""Base SOAP Client
|
||||
@summary: Provides a Basic SOAP client by wrapping the lightweight
|
||||
suds client.
|
||||
@see: https://fedorahosted.org/suds/
|
||||
"""
|
||||
def __init__(self, wsdl, ns_import_location=None, location=None,
|
||||
username=None, password=None, faults=False, plugins=None,
|
||||
cache=None):
|
||||
super(BaseSoapClient, self).__init__()
|
||||
logging.getLogger('suds').setLevel(logging.CRITICAL)
|
||||
|
||||
# Fix import for parsing most WSDLs
|
||||
if ns_import_location is None:
|
||||
ns_import_location = 'http://schemas.xmlsoap.org/soap/encoding/'
|
||||
ns_import = suds_doctor.Import(ns_import_location)
|
||||
doctor = suds_doctor.ImportDoctor(ns_import)
|
||||
|
||||
if plugins is None:
|
||||
plugins = [doctor]
|
||||
else:
|
||||
plugins.extend([doctor])
|
||||
self.client = suds.client.Client(wsdl,
|
||||
location=location,
|
||||
username=username,
|
||||
password=password,
|
||||
faults=faults,
|
||||
plugins=plugins,
|
||||
cache=cache)
|
||||
|
||||
def get_service(self):
|
||||
""" Get Service
|
||||
@summary: Gets the service methods from the instantiated client.
|
||||
@return: self.client.service
|
||||
@rtype: Tuple
|
||||
"""
|
||||
return self.client.service
|
46
plugins/soap/setup.py
Normal file
46
plugins/soap/setup.py
Normal file
@ -0,0 +1,46 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
from setuptools import setup, find_packages
|
||||
import sys
|
||||
from setuptools.command.test import test as TestCommand
|
||||
|
||||
|
||||
# tox integration
|
||||
class Tox(TestCommand):
|
||||
def finalize_options(self):
|
||||
TestCommand.finalize_options(self)
|
||||
self.test_args = []
|
||||
self.test_suite = True
|
||||
|
||||
def run_tests(self):
|
||||
# import here, cause outside the eggs aren't loaded
|
||||
import tox
|
||||
errno = tox.cmdline(self.test_args)
|
||||
sys.exit(errno)
|
||||
|
||||
setup(
|
||||
name='cafe_soap_plugin',
|
||||
version='0.0.1',
|
||||
description='The Common Automation Framework Engine',
|
||||
author='Rackspace Cloud QE',
|
||||
author_email='cloud-cafe@lists.rackspace.com',
|
||||
url='http://rackspace.com',
|
||||
packages=find_packages(),
|
||||
namespace_packages=['cafe'],
|
||||
install_requires=['suds'],
|
||||
tests_require=['tox'],
|
||||
cmdclass={'test': Tox},
|
||||
zip_safe=False)
|
4
plugins/soap/test-requirements.txt
Normal file
4
plugins/soap/test-requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
tox
|
||||
mock
|
||||
flake8
|
||||
nose
|
15
plugins/soap/tests/__init__.py
Normal file
15
plugins/soap/tests/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
15
plugins/soap/tests/engine/__init__.py
Normal file
15
plugins/soap/tests/engine/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
15
plugins/soap/tests/engine/clients/__init__.py
Normal file
15
plugins/soap/tests/engine/clients/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
49
plugins/soap/tests/engine/clients/test_soap.py
Normal file
49
plugins/soap/tests/engine/clients/test_soap.py
Normal file
@ -0,0 +1,49 @@
|
||||
"""
|
||||
Copyright 2014 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from mock import MagicMock
|
||||
import unittest
|
||||
|
||||
from cafe.engine.soap.client import BaseSoapClient
|
||||
|
||||
|
||||
class SoapClientTests(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SoapClientTests, cls).setUpClass()
|
||||
|
||||
cls.wsdl = "http://fake.wsdl"
|
||||
cls.endpoint = "http://fake.url.endpoint"
|
||||
cls.username = "fake_username"
|
||||
cls.password = "fakepassword12345"
|
||||
cls.plugins = None
|
||||
|
||||
def test_create_soap_client_object(self):
|
||||
soap_client_object = BaseSoapClient
|
||||
soap_client_object.__init__ = MagicMock()
|
||||
soap_client_object.__init__(
|
||||
wsdl=self.wsdl,
|
||||
endpoint=self.endpoint,
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
plugins=self.plugins)
|
||||
soap_client_object.__init__.assert_called_once_with(
|
||||
wsdl=self.wsdl,
|
||||
endpoint=self.endpoint,
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
plugins=self.plugins)
|
17
plugins/soap/tox.ini
Normal file
17
plugins/soap/tox.ini
Normal file
@ -0,0 +1,17 @@
|
||||
[tox]
|
||||
envlist=pep8,py27
|
||||
|
||||
[testenv]
|
||||
setenv=VIRTUAL_ENV={envdir}
|
||||
|
||||
deps=-r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:py27]
|
||||
commands=nosetests {toxinidir}
|
||||
|
||||
[testenv:pep8]
|
||||
commands=flake8
|
||||
|
||||
[flake8]
|
||||
ignore=F401
|
||||
exclude=.git,.idea,docs,.tox,bin,dist,tools,*.egg-info
|
Loading…
x
Reference in New Issue
Block a user