# Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# All 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.
"""Unit tests for the API Request internals."""
import copy
from oslo_utils import timeutils
from nova.api.ec2 import apirequest
from nova import test
class APIRequestTestCase(test.NoDBTestCase):
def setUp(self):
super(APIRequestTestCase, self).setUp()
self.req = apirequest.APIRequest("FakeController", "FakeAction",
"FakeVersion", {})
self.resp = {
'string': 'foo',
'int': 1,
'long': long(1),
'bool': False,
'dict': {
'string': 'foo',
'int': 1,
}
}
# The previous will produce an output that looks like the
# following (excusing line wrap for 80 cols):
#
#
# uuid
# 1
#
# 1
# foo
#
# false
# foo
#
#
# We don't attempt to ever test for the full document because
# hash seed order might impact it's rendering order. The fact
# that running the function doesn't explode is a big part of
# the win.
def test_render_response_ascii(self):
data = self.req._render_response(self.resp, 'uuid')
self.assertIn('