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

21 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""" 

19 

20from oslo_serialization import jsonutils 

21 

22from manila.scheduler.filters import base_host 

23from manila import test 

24 

25 

26class TestFilter(test.TestCase): 

27 pass 

28 

29 

30class TestBogusFilter(object): 

31 """Class that doesn't inherit from BaseHostFilter.""" 

32 pass 

33 

34 

35class HostFiltersTestCase(test.TestCase): 

36 """Test case for host filters.""" 

37 

38 def setUp(self): 

39 super(HostFiltersTestCase, self).setUp() 

40 self.json_query = jsonutils.dumps( 

41 ['and', ['>=', '$free_ram_mb', 1024], 

42 ['>=', '$free_disk_mb', 200 * 1024]]) 

43 namespace = 'manila.scheduler.filters' 

44 filter_handler = base_host.HostFilterHandler(namespace) 

45 classes = filter_handler.get_all_classes() 

46 self.class_map = {} 

47 for cls in classes: 

48 self.class_map[cls.__name__] = cls 

49 

50 def test_all_filters(self): 

51 # Double check at least a couple of known filters exist 

52 self.assertIn('JsonFilter', self.class_map) 

53 self.assertIn('CapabilitiesFilter', self.class_map) 

54 self.assertIn('AvailabilityZoneFilter', self.class_map)