Coverage for manila/tests/scheduler/test_utils.py: 100%
15 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright 2016 EMC Corporation 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.
16"""
17Tests For utils.
18"""
20import ddt
22from manila.scheduler import utils
23from manila import test
26@ddt.ddt
27class UtilsTestCase(test.TestCase):
28 """Test case for utils."""
30 @ddt.data(
31 ({'extra_specs': {'thin_provisioning': True}}, True),
32 ({'extra_specs': {'thin_provisioning': False}}, False),
33 ({'extra_specs': {'foo': 'bar'}}, True),
34 ({'foo': 'bar'}, True),
35 ({'extra_specs': {'thin_provisioning': '<is> True'}},
36 True),
37 ({'extra_specs': {'thin_provisioning': '<is> False'}},
38 False),
39 ({'extra_specs': {'thin_provisioning': '<not> True'}},
40 False),
41 ({'extra_specs': {}}, True),
42 ({}, True),
43 )
44 @ddt.unpack
45 def test_use_thin_logic(self, properties, use_thin):
46 use_thin_logic = utils.use_thin_logic(properties)
47 self.assertEqual(use_thin, use_thin_logic)
49 @ddt.data(
50 (True, True),
51 (False, False),
52 (None, False),
53 ([True, False], True),
54 ([True], True),
55 ([False], False),
56 ('wrong', False),
57 )
58 @ddt.unpack
59 def test_thin_provisioning(self, thin_capabilities, thin):
60 thin_provisioning = utils.thin_provisioning(thin_capabilities)
61 self.assertEqual(thin, thin_provisioning)