None is a valid default value for base_url and auth_token in the client
Change-Id: Ie31f556c608c876d2ccc9ca275602f48f88a9971 Closes-Bug: #1428652
This commit is contained in:
parent
70bcb2dd03
commit
e38f05b9e1
|
@ -24,14 +24,14 @@ _DEFAULT_URL = 'http://127.0.0.1:5050/v1'
|
|||
|
||||
|
||||
def _prepare(base_url, auth_token):
|
||||
base_url = base_url.rstrip('/')
|
||||
base_url = (base_url or _DEFAULT_URL).rstrip('/')
|
||||
if not base_url.endswith('v1'):
|
||||
base_url += '/v1'
|
||||
headers = {'X-Auth-Token': auth_token}
|
||||
headers = {'X-Auth-Token': auth_token} if auth_token else {}
|
||||
return base_url, headers
|
||||
|
||||
|
||||
def introspect(uuid, base_url=_DEFAULT_URL, auth_token='',
|
||||
def introspect(uuid, base_url=None, auth_token=None,
|
||||
new_ipmi_password=None, new_ipmi_username=None):
|
||||
"""Start introspection for a node.
|
||||
|
||||
|
@ -58,7 +58,7 @@ def introspect(uuid, base_url=_DEFAULT_URL, auth_token='',
|
|||
res.raise_for_status()
|
||||
|
||||
|
||||
def get_status(uuid, base_url=_DEFAULT_URL, auth_token=''):
|
||||
def get_status(uuid, base_url=None, auth_token=None):
|
||||
"""Get introspection status for a node.
|
||||
|
||||
New in ironic-discoverd version 1.0.0.
|
||||
|
@ -78,7 +78,7 @@ def get_status(uuid, base_url=_DEFAULT_URL, auth_token=''):
|
|||
return res.json()
|
||||
|
||||
|
||||
def discover(uuids, base_url=_DEFAULT_URL, auth_token=''):
|
||||
def discover(uuids, base_url=None, auth_token=None):
|
||||
"""Post node UUID's for discovery.
|
||||
|
||||
DEPRECATED. Use introspect instead.
|
||||
|
|
|
@ -66,6 +66,14 @@ class TestIntrospect(unittest.TestCase):
|
|||
params={'new_ipmi_username': 'u', 'new_ipmi_password': 'p'}
|
||||
)
|
||||
|
||||
def test_none_ok(self, mock_post):
|
||||
client.introspect(self.uuid)
|
||||
mock_post.assert_called_once_with(
|
||||
"http://127.0.0.1:5050/v1/introspection/%s" % self.uuid,
|
||||
headers={},
|
||||
params={'new_ipmi_username': None, 'new_ipmi_password': None}
|
||||
)
|
||||
|
||||
|
||||
@mock.patch.object(client.requests, 'post', autospec=True)
|
||||
class TestDiscover(unittest.TestCase):
|
||||
|
|
Loading…
Reference in New Issue