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

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. 

15 

16import webob.exc 

17 

18from manila.api import extensions 

19from manila.api.openstack import wsgi 

20 

21 

22class FoxInSocksController(object): 

23 

24 def index(self, req): 

25 return "Try to say this Mr. Knox, sir..." 

26 

27 

28class FoxInSocksServerControllerExtension(wsgi.Controller): 

29 @wsgi.action('add_tweedle') 

30 def _add_tweedle(self, req, id, body): 

31 

32 return "Tweedle Beetle Added." 

33 

34 @wsgi.action('delete_tweedle') 

35 def _delete_tweedle(self, req, id, body): 

36 

37 return "Tweedle Beetle Deleted." 

38 

39 @wsgi.action('fail') 

40 def _fail(self, req, id, body): 

41 

42 raise webob.exc.HTTPBadRequest(explanation='Tweedle fail') 

43 

44 

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') 

51 

52 

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!' 

59 

60 

61class Foxinsocks(extensions.ExtensionDescriptor): 

62 """The Fox In Socks Extension.""" 

63 

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" 

68 

69 def __init__(self, ext_mgr): 

70 ext_mgr.register(self) 

71 

72 def get_resources(self): 

73 resources = [] 

74 resource = extensions.ResourceExtension('foxnsocks', 

75 FoxInSocksController()) 

76 resources.append(resource) 

77 return resources 

78 

79 def get_controller_extensions(self): 

80 extension_list = [] 

81 

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) 

90 

91 return extension_list