Coverage for manila/tests/share/drivers/netapp/dataontap/protocols/test_base.py: 100%

23 statements  

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

1# Copyright (c) 2015 Clinton Knight. 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""" 

15Mock unit tests for the NetApp driver protocols base class module. 

16""" 

17 

18import ddt 

19 

20from manila.common import constants 

21from manila.share.drivers.netapp.dataontap.protocols import nfs_cmode 

22from manila import test 

23 

24 

25@ddt.ddt 

26class NetAppNASHelperBaseTestCase(test.TestCase): 

27 

28 def test_set_client(self): 

29 # The base class is abstract, so we'll use a subclass to test 

30 # base class functionality. 

31 helper = nfs_cmode.NetAppCmodeNFSHelper() 

32 self.assertIsNone(helper._client) 

33 

34 helper.set_client('fake_client') 

35 self.assertEqual('fake_client', helper._client) 

36 

37 @ddt.data( 

38 {'level': constants.ACCESS_LEVEL_RW, 'readonly': False}, 

39 {'level': constants.ACCESS_LEVEL_RO, 'readonly': True}) 

40 @ddt.unpack 

41 def test_is_readonly(self, level, readonly): 

42 

43 helper = nfs_cmode.NetAppCmodeNFSHelper() 

44 

45 result = helper._is_readonly(level) 

46 

47 self.assertEqual(readonly, result) 

48 

49 @ddt.data( 

50 {'share': {'export_location': 'fake_export'}, 

51 'expected_export': 'fake_export'}, 

52 {'share': {'export_locations': [{'path': 'fake_export'}]}, 

53 'expected_export': 'fake_export'}, 

54 {'share': {'export_locations': 'error_type'}, 

55 'expected_export': None}, 

56 {'share': {'export_locations': []}, 

57 'expected_export': None}, 

58 {'share': {}, 

59 'expected_export': None}) 

60 @ddt.unpack 

61 def test__get_share_export_location(self, share, expected_export): 

62 

63 helper = nfs_cmode.NetAppCmodeNFSHelper() 

64 

65 result = helper._get_share_export_location(share) 

66 

67 self.assertEqual(expected_export, result)