Conform expected validation responses to status standard
Upon review of standard responses, the validation responses were found to be using valid/invalid instead of success/failure. This change changes the values used to be success/failure for the status field in validations. Additionally, this also cleans up the misuse of api version 'v1', making it v1.0 instead on the status responses. Change-Id: Ia10674158648ef0d0c42badc4bd19e1b48b255d9
This commit is contained in:
parent
155c85b56b
commit
295835cf2c
|
@ -290,7 +290,7 @@ Example
|
|||
"message": "Validations failed",
|
||||
"metadata": {},
|
||||
"reason": "Validation",
|
||||
"status": "Invalid"
|
||||
"status": "Failure"
|
||||
}
|
||||
|
||||
Action API
|
||||
|
|
|
@ -240,7 +240,7 @@ or a single directory option must be specified.
|
|||
Example:
|
||||
shipyard create configdocs design --append --filename=site_design.yaml
|
||||
|
||||
.. note::
|
||||
.. note::
|
||||
|
||||
If neither append nor replace are specified, the Shipyard API default value
|
||||
of rejectoncontents will be used.
|
||||
|
|
|
@ -166,9 +166,9 @@ class CommitConfigDocsResource(BaseResource):
|
|||
retry=True
|
||||
)
|
||||
validations = helper.get_validations_for_buffer()
|
||||
if force or validations.get('status') == 'Valid':
|
||||
if force or validations.get('status') == 'Success':
|
||||
helper.tag_buffer(configdocs_helper.COMMITTED)
|
||||
if force and validations.get('status') == 'Invalid':
|
||||
if force and validations.get('status') == 'Failure':
|
||||
# override the status in the response
|
||||
validations['code'] = falcon.HTTP_200
|
||||
if validations.get('message'):
|
||||
|
|
|
@ -549,17 +549,17 @@ class ConfigdocsHelper(object):
|
|||
# Using a list of validation messages and an error count,
|
||||
# formulates and returns a status response dict
|
||||
|
||||
status = 'Valid'
|
||||
status = 'Success'
|
||||
message = 'Validations succeeded'
|
||||
code = falcon.HTTP_200
|
||||
if error_count > 0:
|
||||
status = 'Invalid'
|
||||
status = 'Failure'
|
||||
message = 'Validations failed'
|
||||
code = falcon.HTTP_400
|
||||
|
||||
return {
|
||||
"kind": "Status",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "v1.0",
|
||||
"metadata": {},
|
||||
"status": status,
|
||||
"message": message,
|
||||
|
|
|
@ -53,9 +53,9 @@ DEFAULT_BODY = """
|
|||
STATUS_TEMPL = """
|
||||
{{
|
||||
"kind": "Status",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "v1.0",
|
||||
"metadata": {{}},
|
||||
"status": "Valid",
|
||||
"status": "Success",
|
||||
"message": "{}",
|
||||
"reason": "{}",
|
||||
"details": {{
|
||||
|
|
|
@ -97,11 +97,11 @@ def test_commit_configdocs():
|
|||
with patch.object(ConfigdocsHelper, 'tag_buffer') as mock_method:
|
||||
helper = ConfigdocsHelper(CTX)
|
||||
helper.is_buffer_empty = lambda: False
|
||||
helper.get_validations_for_buffer = lambda: {'status': 'Valid'}
|
||||
helper.get_validations_for_buffer = lambda: {'status': 'Success'}
|
||||
commit_resp = ccdr.commit_configdocs(helper, False)
|
||||
|
||||
mock_method.assert_called_once_with('committed')
|
||||
assert commit_resp['status'] == 'Valid'
|
||||
assert commit_resp['status'] == 'Success'
|
||||
|
||||
commit_resp = None
|
||||
with patch.object(ConfigdocsHelper, 'tag_buffer') as mock_method:
|
||||
|
@ -109,7 +109,7 @@ def test_commit_configdocs():
|
|||
helper.is_buffer_empty = lambda: False
|
||||
helper.get_validations_for_buffer = (
|
||||
lambda: {
|
||||
'status': 'Invalid',
|
||||
'status': 'Failure',
|
||||
'code': '400 Bad Request',
|
||||
'message': 'this is a mock response'
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ def test_commit_configdocs():
|
|||
commit_resp = ccdr.commit_configdocs(helper, False)
|
||||
assert '400' in commit_resp['code']
|
||||
assert commit_resp['message'] is not None
|
||||
assert commit_resp['status'] == 'Invalid'
|
||||
assert commit_resp['status'] == 'Failure'
|
||||
|
||||
|
||||
def test_commit_configdocs_force():
|
||||
|
@ -129,14 +129,14 @@ def test_commit_configdocs_force():
|
|||
with patch.object(ConfigdocsHelper, 'tag_buffer') as mock_method:
|
||||
helper = ConfigdocsHelper(CTX)
|
||||
helper.is_buffer_empty = lambda: False
|
||||
helper.get_validations_for_buffer = lambda: {'status': 'Invalid'}
|
||||
helper.get_validations_for_buffer = lambda: {'status': 'Failure'}
|
||||
commit_resp = ccdr.commit_configdocs(helper, True)
|
||||
|
||||
mock_method.assert_called_once_with('committed')
|
||||
print(commit_resp)
|
||||
assert '200' in commit_resp['code']
|
||||
assert 'FORCED' in commit_resp['message']
|
||||
assert commit_resp['status'] == 'Invalid'
|
||||
assert commit_resp['status'] == 'Failure'
|
||||
|
||||
|
||||
def test_commit_configdocs_buffer_err():
|
||||
|
@ -148,7 +148,7 @@ def test_commit_configdocs_buffer_err():
|
|||
with pytest.raises(ApiError):
|
||||
helper = ConfigdocsHelper(CTX)
|
||||
helper.is_buffer_empty = lambda: True
|
||||
helper.get_validations_for_buffer = lambda: {'status': 'Valid'}
|
||||
helper.get_validations_for_buffer = lambda: {'status': 'Success'}
|
||||
ccdr.commit_configdocs(helper, False)
|
||||
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ def _fake_get_validations_for_component(url,
|
|||
response['response'] = json.loads(("""
|
||||
{
|
||||
"kind": "Status",
|
||||
"apiVersion": "v1",
|
||||
"apiVersion": "v1.0",
|
||||
"metadata": {},
|
||||
"status": "Failure",
|
||||
"message": "%s",
|
||||
|
|
Loading…
Reference in New Issue