shipyard/tests/unit/control/common.py
One-Fine-Day 380fa672c2 Unit Tests for ActionsIdResource
test_actions_id_api.py contains the unit tests for the ActionsIdResource

common.py now contains the functions create_req and create_resp which
have been removed from test_actions_id_api.py and test_base_resource.py

Change-Id: I01cde3e3598f9d6ee25d55267be0c8facc6438f2
2017-12-01 10:06:02 -06:00

66 lines
1.9 KiB
Python

# 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 falcon
from falcon import testing
AUTH_HEADERS = {
'X-SERVICE-IDENTITY-STATUS': 'Confirmed',
'X-IDENTITY-STATUS': 'Confirmed',
'X-SERVICE-USER-NAME': 'testauth',
'X-USER-NAME': 'testauth',
'X-SERVICE-USER-ID': 'testauth',
'X-USER-ID': 'testauth',
'X-SERVICE-USER-DOMAIN-ID': 'default',
'X-USER-DOMAIN-ID': 'default',
'X-SERVICE-PROJECT-ID': 'default',
'X-PROJECT-ID': 'default',
'X-SERVICE-PROJECT-DOMAIN-ID': 'default',
'X-PROJECT-DOMAIN-NAME': 'default',
'X-SERVICE-ROLES': 'Admin',
'X-ROLES': 'Admin',
'X-IS-ADMIN-PROJECT': 'True'
}
def create_req(ctx, body):
'''creates a falcon request'''
env = testing.create_environ(
path='/',
query_string='',
protocol='HTTP/1.1',
scheme='http',
host='falconframework.org',
port=None,
headers={'Content-Type': 'application/json'},
app='',
body=body,
method='POST',
wsgierrors=None,
file_wrapper=None)
req = falcon.Request(env)
req.context = ctx
return req
def create_resp():
'''creates a falcon response'''
resp = falcon.Response()
return resp
def str_responder(*args, **kwargs):
"""Responds with an empty string"""
return ''