1
# Copyright (c) 2013 Intel Corporation.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
16
from testtools import matchers
19
from neutron.api import api_common as common
20
from neutron.tests import base
23
class FakeController(common.NeutronController):
24
_resource_name = 'fake'
27
class APICommonTestCase(base.BaseTestCase):
29
super(APICommonTestCase, self).setUp()
30
self.controller = FakeController(None)
32
def test_prepare_request_body(self):
40
{'param-name': 'name',
42
{'param-name': 'model',
44
{'param-name': 'quote',
46
'default-value': "i'll be back"},
52
'quote': "i'll be back",
55
actual = self.controller._prepare_request_body(body, params)
56
self.assertThat(expect, matchers.Equals(actual))
58
def test_prepare_request_body_none(self):
61
{'param-name': 'quote',
63
'default-value': "I'll be back"},
67
'quote': "I'll be back",
70
actual = self.controller._prepare_request_body(body, params)
71
self.assertThat(expect, matchers.Equals(actual))
73
def test_prepare_request_body_keyerror(self):
76
self.assertRaises(exc.HTTPBadRequest,
77
self.controller._prepare_request_body,
81
def test_prepare_request_param_value_none(self):
88
{'param-name': 'name',
91
self.assertRaises(exc.HTTPBadRequest,
92
self.controller._prepare_request_body,