Coverage for manila/tests/api/extensions/foxinsocks.py: 89%
44 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright 2011 OpenStack LLC.
2# All Rights Reserved.
3#
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
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
14# under the License.
16import webob.exc
18from manila.api import extensions
19from manila.api.openstack import wsgi
22class FoxInSocksController(object):
24 def index(self, req):
25 return "Try to say this Mr. Knox, sir..."
28class FoxInSocksServerControllerExtension(wsgi.Controller):
29 @wsgi.action('add_tweedle')
30 def _add_tweedle(self, req, id, body):
32 return "Tweedle Beetle Added."
34 @wsgi.action('delete_tweedle')
35 def _delete_tweedle(self, req, id, body):
37 return "Tweedle Beetle Deleted."
39 @wsgi.action('fail')
40 def _fail(self, req, id, body):
42 raise webob.exc.HTTPBadRequest(explanation='Tweedle fail')
45class FoxInSocksFlavorGooseControllerExtension(wsgi.Controller):
46 @wsgi.extends
47 def show(self, req, resp_obj, id):
48 # NOTE: This only handles JSON responses.
49 # You can use content type header to test for XML.
50 resp_obj.obj['flavor']['googoose'] = req.GET.get('chewing')
53class FoxInSocksFlavorBandsControllerExtension(wsgi.Controller):
54 @wsgi.extends
55 def show(self, req, resp_obj, id):
56 # NOTE: This only handles JSON responses.
57 # You can use content type header to test for XML.
58 resp_obj.obj['big_bands'] = 'Pig Bands!'
61class Foxinsocks(extensions.ExtensionDescriptor):
62 """The Fox In Socks Extension."""
64 name = "Fox In Socks"
65 alias = "FOXNSOX"
66 namespace = "http://www.fox.in.socks/api/ext/pie/v1.0"
67 updated = "2011-01-22T13:25:27-06:00"
69 def __init__(self, ext_mgr):
70 ext_mgr.register(self)
72 def get_resources(self):
73 resources = []
74 resource = extensions.ResourceExtension('foxnsocks',
75 FoxInSocksController())
76 resources.append(resource)
77 return resources
79 def get_controller_extensions(self):
80 extension_list = []
82 extension_set = [
83 (FoxInSocksServerControllerExtension, 'servers'),
84 (FoxInSocksFlavorGooseControllerExtension, 'flavors'),
85 (FoxInSocksFlavorBandsControllerExtension, 'flavors'), ]
86 for klass, collection in extension_set:
87 controller = klass()
88 ext = extensions.ControllerExtension(self, collection, controller)
89 extension_list.append(ext)
91 return extension_list