c017947f58
Make opt 'enabled_share_protocols' expect share protocol names using any case. Also, remove concatenation of translated messages and make explicit unicode-transformation or these messages that is required when lazy translation is enabled. That is case of Manila. See http://docs.openstack.org/developer/oslo.i18n/usage.html#lazy-translation Change-Id: Iadf41abd5ac62fcce0c0f63cd9a376a2c6eadd6e Closes-Bug: #1475668
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
# Copyright 2015 Mirantis Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import ddt
|
|
|
|
from manila.common import config
|
|
from manila.common import constants
|
|
from manila import exception
|
|
from manila import test
|
|
from manila.tests import utils as test_utils
|
|
|
|
VALID_CASES = [proto.lower() for proto in constants.SUPPORTED_SHARE_PROTOCOLS]
|
|
VALID_CASES.extend([proto.upper() for proto in VALID_CASES])
|
|
VALID_CASES.append(','.join(case for case in VALID_CASES))
|
|
|
|
|
|
@ddt.ddt
|
|
class VerifyConfigShareProtocolsTestCase(test.TestCase):
|
|
|
|
@ddt.data(*VALID_CASES)
|
|
def test_verify_share_protocols_valid_cases(self, proto):
|
|
data = dict(DEFAULT=dict(enabled_share_protocols=proto))
|
|
with test_utils.create_temp_config_with_opts(data):
|
|
config.verify_share_protocols()
|
|
|
|
@ddt.data(None, '', 'fake', [], ['fake'], [VALID_CASES[0] + 'fake'])
|
|
def test_verify_share_protocols_invalid_cases(self, proto):
|
|
data = dict(DEFAULT=dict(enabled_share_protocols=proto))
|
|
with test_utils.create_temp_config_with_opts(data):
|
|
self.assertRaises(
|
|
exception.ManilaException, config.verify_share_protocols)
|