Shipyard Client API for Configdocs Status
Shipyard API to discover buffered and committed collections of configdocs 2 of 4 Commits (API, CLI, Documentation are in separate commits) API Client -added url access function in shipyard_api_client.py -unit tests are located in test_shipyard_api_client.py Change-Id: I9c78724a96e803a70689b0028601f043ebc3b46c
This commit is contained in:
parent
9aa13ac5e9
commit
6994db10ca
@ -25,6 +25,7 @@ class ApiPaths(enum.Enum):
|
|||||||
includes api/v1.0, so it is not repeated here.
|
includes api/v1.0, so it is not repeated here.
|
||||||
"""
|
"""
|
||||||
_BASE_URL = '{}/'
|
_BASE_URL = '{}/'
|
||||||
|
GET_CONFIGDOCS = _BASE_URL + 'configdocs'
|
||||||
POST_GET_CONFIG = _BASE_URL + 'configdocs/{}'
|
POST_GET_CONFIG = _BASE_URL + 'configdocs/{}'
|
||||||
GET_RENDERED = _BASE_URL + 'renderedconfigdocs'
|
GET_RENDERED = _BASE_URL + 'renderedconfigdocs'
|
||||||
COMMIT_CONFIG = _BASE_URL + 'commitconfigdocs'
|
COMMIT_CONFIG = _BASE_URL + 'commitconfigdocs'
|
||||||
@ -79,6 +80,14 @@ class ShipyardClient(BaseClient):
|
|||||||
collection_id)
|
collection_id)
|
||||||
return self.get_resp(url, query_params)
|
return self.get_resp(url, query_params)
|
||||||
|
|
||||||
|
def get_configdocs_status(self):
|
||||||
|
"""
|
||||||
|
Get the status of the collection of documents from shipyard
|
||||||
|
:returns: Response object
|
||||||
|
"""
|
||||||
|
url = ApiPaths.GET_CONFIGDOCS.value.format(self.get_endpoint())
|
||||||
|
return self.get_resp(url)
|
||||||
|
|
||||||
def get_rendereddocs(self, version='buffer'):
|
def get_rendereddocs(self, version='buffer'):
|
||||||
"""
|
"""
|
||||||
:param str version: committed|buffer
|
:param str version: committed|buffer
|
||||||
|
@ -58,8 +58,7 @@ def get_api_client():
|
|||||||
context = ShipyardClientContext(
|
context = ShipyardClientContext(
|
||||||
debug=True,
|
debug=True,
|
||||||
keystone_auth=keystone_auth,
|
keystone_auth=keystone_auth,
|
||||||
context_marker='88888888-4444-4444-4444-121212121212'
|
context_marker='88888888-4444-4444-4444-121212121212')
|
||||||
)
|
|
||||||
return ShipyardClient(context)
|
return ShipyardClient(context)
|
||||||
|
|
||||||
|
|
||||||
@ -89,6 +88,16 @@ def test_get_config_docs(*args):
|
|||||||
assert params['version'] == version
|
assert params['version'] == version
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch.object(BaseClient, 'post_resp', replace_post_rep)
|
||||||
|
@mock.patch.object(BaseClient, 'get_resp', replace_get_resp)
|
||||||
|
@mock.patch.object(BaseClient, 'get_endpoint', replace_get_endpoint)
|
||||||
|
def test_get_configdocs_status(*args):
|
||||||
|
shipyard_client = get_api_client()
|
||||||
|
result = shipyard_client.get_configdocs_status()
|
||||||
|
assert result['url'] == '{}/configdocs'.format(
|
||||||
|
shipyard_client.get_endpoint())
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(BaseClient, 'post_resp', replace_post_rep)
|
@mock.patch.object(BaseClient, 'post_resp', replace_post_rep)
|
||||||
@mock.patch.object(BaseClient, 'get_resp', replace_get_resp)
|
@mock.patch.object(BaseClient, 'get_resp', replace_get_resp)
|
||||||
@mock.patch.object(BaseClient, 'get_endpoint', replace_get_endpoint)
|
@mock.patch.object(BaseClient, 'get_endpoint', replace_get_endpoint)
|
||||||
@ -121,9 +130,7 @@ def test_commit_configs(*args):
|
|||||||
def test_get_actions(*args):
|
def test_get_actions(*args):
|
||||||
shipyard_client = get_api_client()
|
shipyard_client = get_api_client()
|
||||||
result = shipyard_client.get_actions()
|
result = shipyard_client.get_actions()
|
||||||
assert result['url'] == '{}/actions'.format(
|
assert result['url'] == '{}/actions'.format(shipyard_client.get_endpoint())
|
||||||
shipyard_client.get_endpoint()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(BaseClient, 'post_resp', replace_post_rep)
|
@mock.patch.object(BaseClient, 'post_resp', replace_post_rep)
|
||||||
@ -135,9 +142,7 @@ def test_post_actions(*args):
|
|||||||
parameters = {'hello': 'world'}
|
parameters = {'hello': 'world'}
|
||||||
result = shipyard_client.post_actions(name, parameters)
|
result = shipyard_client.post_actions(name, parameters)
|
||||||
data = json.loads(result['data'])
|
data = json.loads(result['data'])
|
||||||
assert result['url'] == '{}/actions'.format(
|
assert result['url'] == '{}/actions'.format(shipyard_client.get_endpoint())
|
||||||
shipyard_client.get_endpoint()
|
|
||||||
)
|
|
||||||
assert data['name'] == name
|
assert data['name'] == name
|
||||||
assert data['parameters']['hello'] == 'world'
|
assert data['parameters']['hello'] == 'world'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user