Coverage for manila/tests/fake_zfssa.py: 73%

74 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); you may 

4# not use this file except in compliance with the License. You may obtain 

5# a copy of the License at 

6# 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

12# License for the specific language governing permissions and limitations 

13# under the License. 

14""" 

15Fake ZFS Storage Appliance, for unit testing. 

16""" 

17 

18 

19class FakeResponse(object): 

20 def __init__(self, statuscode): 

21 self.status = statuscode 

22 self.data = 'data' 

23 

24 

25class FakeZFSSA(object): 

26 """Fake ZFS SA.""" 

27 def __init__(self): 

28 self.user = None 

29 self.host = 'fakehost' 

30 self.url = 'fakeurl' 

31 self.rclient = None 

32 

33 def login(self, user): 

34 self.user = user 

35 

36 def set_host(self, host, timeout=None): 

37 self.host = host 

38 

39 def enable_service(self, service): 

40 return True 

41 

42 def create_project(self, pool, project, arg): 

43 pass 

44 

45 def get_share(self, pool, project, share): 

46 pass 

47 

48 def create_share(self, pool, project, share): 

49 pass 

50 

51 def delete_share(self, pool, project, share): 

52 pass 

53 

54 def create_snapshot(self, pool, project, share): 

55 pass 

56 

57 def delete_snapshot(self, pool, project, share, snapshot): 

58 pass 

59 

60 def clone_snapshot(self, pool, project, share, snapshot, clone, size): 

61 pass 

62 

63 def has_clones(self, pool, project, vol, snapshot): 

64 return False 

65 

66 def modify_share(self, pool, project, share, arg): 

67 pass 

68 

69 def allow_access_nfs(self, pool, project, share, access): 

70 pass 

71 

72 def deny_access_nfs(self, pool, project, share, access): 

73 pass 

74 

75 def get_project_stats(self, pool, project): 

76 pass 

77 

78 def create_schema(self, schema): 

79 pass 

80 

81 

82class FakeRestClient(object): 

83 """Fake ZFSSA Rest Client.""" 

84 def __init__(self): 

85 self.url = None 

86 self.headers = None 

87 self.log_function = None 

88 self.local = None 

89 self.base_path = None 

90 self.timeout = 60 

91 self.do_logout = False 

92 self.auth_str = None 

93 

94 def _path(self, path, base_path=None): 

95 pass 

96 

97 def _authoriza(self): 

98 pass 

99 

100 def login(self, auth_str): 

101 pass 

102 

103 def logout(self): 

104 pass 

105 

106 def islogin(self): 

107 pass 

108 

109 def request(self, path, request, body=None, **kwargs): 

110 pass 

111 

112 def get(self, path, **kwargs): 

113 pass 

114 

115 def post(self, path, body="", **kwargs): 

116 pass 

117 

118 def put(self, path, body="", **kwargs): 

119 pass 

120 

121 def delete(self, path, **kwargs): 

122 pass 

123 

124 def head(self, path, **kwargs): 

125 pass