
Rather than always returning JSON or YAML, add functionality to return table responses when applicable for ease of reading. Adds some marker exceptions to the Shipyard API Client to handle cases where the user of the client would generally want to take a specific and repeatable course of action instead of handling the response in a case-by-case basis. Moved cli action testing to use the responses library instead of as many internal mocks. Added test response generators for standard api responses. Change-Id: I3a593fb29b6e76d971adc7f3bb3a4b7f378ed091
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
# 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.
|
|
|
|
# For testing purposes only
|
|
|
|
|
|
def replace_get_endpoint():
|
|
"""Replaces the get endpoint call to isolate tests"""
|
|
return 'http://shipyard-test'
|
|
|
|
|
|
def replace_post_rep(self, url, query_params={}, data={}, content_type=''):
|
|
"""
|
|
replaces call to shipyard client
|
|
:returns: dict with url and parameters
|
|
"""
|
|
return {'url': url, 'params': query_params, 'data': data}
|
|
|
|
|
|
def replace_get_resp(self, url, query_params={}, json=False):
|
|
"""
|
|
replaces call to shipyard client
|
|
:returns: dict with url and parameters
|
|
"""
|
|
return {'url': url, 'params': query_params}
|