Unit tests for health/versions controller
This PS adds unit tests for health and versions controller. In doing so, it was discovered that there was a bug related to unconditionally adding a response header of content-type: x-yaml to the response, because this is not allowed when the response is a 204. This PS also fixes that bug. Change-Id: If97cb3bfaca8f71416c2664f3af9cbf96329c3b4
This commit is contained in:
parent
a3f0bafb7f
commit
f67968d16d
|
@ -148,7 +148,8 @@ class YAMLTranslator(HookableMiddlewareMixin, object):
|
|||
|
||||
def process_response(self, req, resp, resource):
|
||||
"""Converts responses to ``application/x-yaml`` content type."""
|
||||
resp.set_header('Content-Type', 'application/x-yaml')
|
||||
if resp.status != '204 No Content':
|
||||
resp.set_header('Content-Type', 'application/x-yaml')
|
||||
|
||||
for attr in ('body', 'data'):
|
||||
if not hasattr(resp, attr):
|
||||
|
|
|
@ -16,6 +16,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: create
|
||||
desc: Create initial documents
|
||||
|
|
|
@ -24,6 +24,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: create_a
|
||||
desc: Create documents in one bucket (a)
|
||||
|
|
|
@ -43,6 +43,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: initialize
|
||||
desc: Create initial documents
|
||||
|
|
|
@ -16,6 +16,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: add_bucket_a
|
||||
desc: Create documents for bucket a
|
||||
|
|
|
@ -15,6 +15,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: initialize
|
||||
desc: Create initial documents
|
||||
|
|
|
@ -17,6 +17,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
# Validates whether creating a revision works.
|
||||
# Required parameters:
|
||||
|
@ -60,6 +61,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
# Validates whether revision was deleted.
|
||||
# Required parameters:
|
||||
|
|
|
@ -26,6 +26,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: create_a
|
||||
desc: Create documents in bucket a
|
||||
|
|
|
@ -17,6 +17,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: initialize
|
||||
desc: Create initial documents
|
||||
|
|
|
@ -17,6 +17,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: initialize
|
||||
desc: Create initial documents
|
||||
|
|
|
@ -14,6 +14,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: initialize
|
||||
desc: Create initial documents
|
||||
|
|
|
@ -34,6 +34,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
# Create a revision implicitly by creating a document.
|
||||
- name: initialize
|
||||
|
@ -116,6 +117,7 @@ tests:
|
|||
desc: Verify deleting tag works
|
||||
DELETE: /api/v1.0/revisions/$HISTORY['initialize'].$RESPONSE['$.[0].status.revision']/tags/foo
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: verify_tag_delete
|
||||
desc: Verify listing tags contains non-deleted tag
|
||||
|
@ -145,6 +147,7 @@ tests:
|
|||
desc: Verify deleting tag works
|
||||
DELETE: /api/v1.0/revisions/$HISTORY['initialize'].$RESPONSE['$.[0].status.revision']/tags
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: verify_revision_detail_deleted_all
|
||||
desc: Verify empty tags on revision detail
|
||||
|
|
|
@ -23,6 +23,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: initialize
|
||||
desc: Create initial documents
|
||||
|
|
|
@ -19,6 +19,7 @@ tests:
|
|||
desc: Begin testing from known state.
|
||||
DELETE: /api/v1.0/revisions
|
||||
status: 204
|
||||
response_headers: null
|
||||
|
||||
- name: create_schema
|
||||
desc: Add example schema
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from deckhand.tests.unit.control import base as test_base
|
||||
|
||||
|
||||
class TestHealthController(test_base.BaseControllerTest):
|
||||
|
||||
def test_get_health(self):
|
||||
resp = self.app.simulate_get(
|
||||
'/api/v1.0/health', headers={'Content-Type': 'application/x-yaml'})
|
||||
self.assertEqual(204, resp.status_code)
|
|
@ -0,0 +1,32 @@
|
|||
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import yaml
|
||||
|
||||
from deckhand.tests.unit.control import base as test_base
|
||||
|
||||
|
||||
class TestVersionsController(test_base.BaseControllerTest):
|
||||
|
||||
def test_list_versions(self):
|
||||
resp = self.app.simulate_get(
|
||||
'/versions', headers={'Content-Type': 'application/x-yaml'})
|
||||
expected = {
|
||||
'v1.0': {
|
||||
'path': '/api/v1.0',
|
||||
'status': 'stable'
|
||||
}
|
||||
}
|
||||
self.assertEqual(200, resp.status_code)
|
||||
self.assertEqual(expected, yaml.safe_load(resp.text))
|
Loading…
Reference in New Issue