refactors nios api shared code to handle provider better (#35393)

* refactors nios api shared code to handle provider better

This change refactors the shared code to be easily shared between
modules, plugins and dynamic inventory scripts.  All parts now implement
the provider arguments uniformly.

This also provides a centralized fix to suppress urllib3 warnings coming
from the requests library implemented by infoblox_client

* fix up pep8 errors

* fix missing var name
This commit is contained in:
Peter Sprygada 2018-01-27 08:03:06 -05:00 committed by GitHub
parent 1f1402ea68
commit c2d3b9cbd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 90 additions and 70 deletions

View file

@ -30,24 +30,18 @@ class TestNiosApi(unittest.TestCase):
self.mock_connector.stop()
def test_get_provider_spec(self):
provider_options = ['host', 'username', 'password', 'ssl_verify',
provider_options = ['host', 'username', 'password', 'ssl_verify', 'silent_ssl_warnings',
'http_request_timeout', 'http_pool_connections',
'http_pool_maxsize', 'max_retries', 'wapi_version']
res = api.get_provider_spec()
res = api.WapiBase.provider_spec
self.assertIsNotNone(res)
self.assertIn('provider', res)
self.assertIn('options', res['provider'])
returned_options = res['provider']['options']
self.assertEqual(sorted(provider_options), sorted(returned_options.keys()))
def test_wapi_base(self):
wapi = api.WapiBase(self.module)
with self.assertRaises(NotImplementedError):
wapi.run(None, None)
def _get_wapi(self, test_object):
wapi = api.Wapi(self.module)
wapi = api.WapiModule(self.module)
wapi.get_object = Mock(name='get_object', return_value=test_object)
wapi.create_object = Mock(name='create_object')
wapi.update_object = Mock(name='update_object')