Fix shipyard encoding of status response
Fixes 2 issues with getting configdocs. First, this updates the cli to use a more simple optional argument rather than consuming all following arguments on get configdocs commands. Second, this fixes the API to encode the response into json before trying to return it, preventing an exception on a configdocs status GET. Change-Id: Ia24c35a0261bc93d7cb8f8258bec682721064f3c
This commit is contained in:
parent
b379477236
commit
95784c03ed
@ -39,7 +39,7 @@ class ConfigDocsStatusResource(BaseResource):
|
||||
def on_get(self, req, resp):
|
||||
"""Returns a list of the configdocs and their statuses"""
|
||||
helper = ConfigdocsHelper(req.context)
|
||||
resp.body = helper.get_configdocs_status()
|
||||
resp.body = self.to_json(helper.get_configdocs_status())
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ SHORT_DESC_CONFIGDOCS = ("Retrieve documents loaded into Shipyard, either "
|
||||
|
||||
@get.command(
|
||||
name='configdocs', help=DESC_CONFIGDOCS, short_help=SHORT_DESC_CONFIGDOCS)
|
||||
@click.argument('collection', nargs=-1, required=False)
|
||||
@click.argument('collection', required=False)
|
||||
@click.option(
|
||||
'--committed',
|
||||
'-c',
|
||||
|
@ -58,7 +58,7 @@ def test_get_configdocs_with_passing_collection(*args):
|
||||
# verify GetConfigdocs is called when a collection is entered
|
||||
with patch.object(GetConfigdocs, '__init__') as mock_method:
|
||||
runner.invoke(shipyard, [auth_vars, 'get', 'configdocs', collection])
|
||||
mock_method.assert_called_once_with(ANY, (collection, ), 'buffer')
|
||||
mock_method.assert_called_once_with(ANY, 'design', 'buffer')
|
||||
|
||||
|
||||
def test_get_configdocs_without_passing_collection(*args):
|
||||
|
@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
""" Tests for the configdocs_api"""
|
||||
import json
|
||||
import mock
|
||||
from mock import ANY, patch
|
||||
|
||||
@ -39,7 +40,7 @@ class TestConfigDocsStatusResource():
|
||||
result = api_client.simulate_get(
|
||||
"/api/v1.0/configdocs", headers=common.AUTH_HEADERS)
|
||||
assert result.status_code == 200
|
||||
assert result.text == common.str_responder()
|
||||
assert result.text == json.dumps(common.str_responder(), default=str)
|
||||
assert result.headers[
|
||||
'content-type'] == 'application/json; charset=UTF-8'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user