Coverage for manila/tests/scheduler/filters/test_extra_specs_ops.py: 100%

12 statements  

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

1# Copyright 2011 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""" 

17Tests For Scheduler Host Filters. 

18""" 

19import ddt 

20 

21from manila.scheduler.filters import extra_specs_ops 

22from manila import test 

23 

24 

25@ddt.ddt 

26class ExtraSpecsOpsTestCase(test.TestCase): 

27 def _do_extra_specs_ops_test(self, value, req, matches): 

28 assertion = self.assertTrue if matches else self.assertFalse 

29 assertion(extra_specs_ops.match(value, req)) 

30 

31 @ddt.unpack 

32 @ddt.data( 

33 ('1', '1', True), 

34 ('', '1', False), 

35 ('3', '1', False), 

36 ('222', '2', False), 

37 ('4', '> 2', False), 

38 ('123', '= 123', True), 

39 ('124', '= 123', True), 

40 ('34', '=234', False), 

41 ('34', '=', False), 

42 ('123', 's== 123', True), 

43 ('1234', 's== 123', False), 

44 ('1234', 's!= 123', True), 

45 ('123', 's!= 123', False), 

46 ('1000', 's>= 234', False), 

47 ('1234', 's<= 1000', False), 

48 ('2', 's< 12', False), 

49 ('12', 's> 2', False), 

50 ('12311321', '<in> 11', True), 

51 ('12311321', '<in> 12311321', True), 

52 ('12311321', '<in> 12311321 <in>', True), 

53 ('12310321', '<in> 11', False), 

54 ('12310321', '<in> 11 <in>', False), 

55 ('abc', '<in> ABC', True), 

56 (True, 'True', True), 

57 (True, '<is> True', True), 

58 (True, '<is> False', False), 

59 (False, 'False', True), 

60 (False, '<is> False', True), 

61 (False, '<is> True', False), 

62 (False, 'Nonsense', False), 

63 (False, '<is> Nonsense', True), 

64 (True, 'False', False), 

65 (False, 'True', False), 

66 ('12', '<or> 11 <or> 12', True), 

67 ('13', '<or> 11 <or> 12', False), 

68 ('13', '<or> 11 <or> 12 <or>', False), 

69 ('abc', '<or> ABC <or> def', True), 

70 ('2', '<= 10', True), 

71 ('3', '<= 2', False), 

72 ('3', '>= 1', True), 

73 ('2', '>= 3', False), 

74 ('nfs', 'NFS', True), 

75 ('NFS', 'nfs', True), 

76 ('cifs', 'nfs', False), 

77 ) 

78 def test_extra_specs_matches_simple(self, value, req, matches): 

79 self._do_extra_specs_ops_test( 

80 value, req, matches)