Coverage for manila/tests/share/drivers/nexenta/test_utils.py: 100%
12 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 Nexenta Systems, Inc.
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.
16import ddt
17from oslo_utils import units
19from manila.share.drivers.nexenta import utils
20from manila import test
23@ddt.ddt
24class TestNexentaUtils(test.TestCase):
26 @ddt.data(
27 # Test empty value
28 (None, 0),
29 ('', 0),
30 ('0', 0),
31 ('12', 12),
32 # Test int values
33 (10, 10),
34 # Test bytes string
35 ('1b', 1),
36 ('1B', 1),
37 ('1023b', 1023),
38 ('0B', 0),
39 # Test other units
40 ('1M', units.Mi),
41 ('1.0M', units.Mi),
42 )
43 @ddt.unpack
44 def test_str2size(self, value, result):
45 self.assertEqual(result, utils.str2size(value))
47 def test_str2size_input_error(self):
48 # Invalid format value
49 self.assertRaises(ValueError, utils.str2size, 'A')