
We had this library capped at a release that is a few years old. Now that we have dropped py2 testing, we can pick up the latest version. This uncovered a few things to clean up. Mostly the fact that mock is now a part of the StdLib unittest since Python 3.3. Change-Id: I27484dd4c25378413ff16e97a35a1a46062357bc Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
86 lines
2.8 KiB
Python
86 lines
2.8 KiB
Python
# 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.
|
|
#
|
|
|
|
from unittest import mock
|
|
|
|
from openstackclient.common import configuration
|
|
from openstackclient.tests.unit import fakes
|
|
from openstackclient.tests.unit import utils
|
|
|
|
|
|
class TestConfiguration(utils.TestCommand):
|
|
|
|
columns = (
|
|
'auth.password',
|
|
'auth.token',
|
|
'auth.username',
|
|
'identity_api_version',
|
|
'region',
|
|
)
|
|
datalist = (
|
|
configuration.REDACTED,
|
|
configuration.REDACTED,
|
|
fakes.USERNAME,
|
|
fakes.VERSION,
|
|
fakes.REGION_NAME,
|
|
)
|
|
|
|
opts = [mock.Mock(secret=True, dest="password"),
|
|
mock.Mock(secret=True, dest="token")]
|
|
|
|
@mock.patch("keystoneauth1.loading.base.get_plugin_options",
|
|
return_value=opts)
|
|
def test_show(self, m_get_plugin_opts):
|
|
arglist = []
|
|
verifylist = [('mask', True)]
|
|
cmd = configuration.ShowConfiguration(self.app, None)
|
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
|
|
|
columns, data = cmd.take_action(parsed_args)
|
|
|
|
self.assertEqual(self.columns, columns)
|
|
self.assertEqual(self.datalist, data)
|
|
|
|
@mock.patch("keystoneauth1.loading.base.get_plugin_options",
|
|
return_value=opts)
|
|
def test_show_unmask(self, m_get_plugin_opts):
|
|
arglist = ['--unmask']
|
|
verifylist = [('mask', False)]
|
|
cmd = configuration.ShowConfiguration(self.app, None)
|
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
|
|
|
columns, data = cmd.take_action(parsed_args)
|
|
|
|
self.assertEqual(self.columns, columns)
|
|
datalist = (
|
|
fakes.PASSWORD,
|
|
fakes.AUTH_TOKEN,
|
|
fakes.USERNAME,
|
|
fakes.VERSION,
|
|
fakes.REGION_NAME,
|
|
)
|
|
self.assertEqual(datalist, data)
|
|
|
|
@mock.patch("keystoneauth1.loading.base.get_plugin_options",
|
|
return_value=opts)
|
|
def test_show_mask(self, m_get_plugin_opts):
|
|
arglist = ['--mask']
|
|
verifylist = [('mask', True)]
|
|
cmd = configuration.ShowConfiguration(self.app, None)
|
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
|
|
|
columns, data = cmd.take_action(parsed_args)
|
|
|
|
self.assertEqual(self.columns, columns)
|
|
self.assertEqual(self.datalist, data)
|