Coverage for manila/tests/fake_volume.py: 80%

40 statements  

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

1# Copyright 2013 OpenStack Foundation 

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 

16 

17from oslo_config import cfg 

18 

19CONF = cfg.CONF 

20 

21 

22class FakeVolume(object): 

23 def __init__(self, **kwargs): 

24 self.id = kwargs.pop('id', 'fake_vol_id') 

25 self.status = kwargs.pop('status', 'available') 

26 self.device = kwargs.pop('device', '') 

27 for key, value in kwargs.items(): 

28 setattr(self, key, value) 

29 

30 def __getitem__(self, attr): 

31 return getattr(self, attr) 

32 

33 

34class FakeVolumeSnapshot(object): 

35 def __init__(self, **kwargs): 

36 self.id = kwargs.pop('id', 'fake_volsnap_id') 

37 self.status = kwargs.pop('status', 'available') 

38 for key, value in kwargs.items(): 

39 setattr(self, key, value) 

40 

41 def __getitem__(self, attr): 

42 return getattr(self, attr) 

43 

44 

45class API(object): 

46 """Fake Volume API.""" 

47 def get(self, *args, **kwargs): 

48 pass 

49 

50 def create_snapshot_force(self, *args, **kwargs): 

51 pass 

52 

53 def get_snapshot(self, *args, **kwargs): 

54 pass 

55 

56 def delete_snapshot(self, *args, **kwargs): 

57 pass 

58 

59 def create(self, *args, **kwargs): 

60 pass 

61 

62 def extend(self, *args, **kwargs): 

63 pass 

64 

65 def get_all(self, search_opts): 

66 pass 

67 

68 def delete(self, volume_id): 

69 pass 

70 

71 def get_all_snapshots(self, search_opts): 

72 pass 

73 

74 def wait_for_available_volume(self, volume, timeout, **kwargs): 

75 return volume