# Path: magnumclient/common/cliutils.py
# DEPRECATION_BASE = ('%sThe --%s parameter is deprecated and '
#                     'will be removed in a future release. Use the '
#                     '<%s> positional parameter %s.')
# NAME_DEPRECATION_HELP = DEPRECATION_BASE % ('', 'name', 'name', 'instead')
# NAME_DEPRECATION_WARNING = DEPRECATION_BASE % (
#     'WARNING: ', 'name', 'name', 'to avoid seeing this message')
# CLUSTER_DEPRECATION_HELP = DEPRECATION_BASE % ('', 'cluster', 'cluster',
#                                                'instead')
# CLUSTER_DEPRECATION_WARNING = DEPRECATION_BASE % (
#     'WARNING: ', 'cluster', 'cluster', 'to avoid seeing this message')
# MAGNUM_CLIENT_DEPRECATION_WARNING = (
#     'WARNING: The magnum client is deprecated and will be removed in a future '
#     'release.\nUse the OpenStack client to avoid seeing this message.')
# def deprecation_message(preamble, new_name):
#     def __init__(self, missing):
#     def __init__(self, param, dupes):
# def validate_args(fn, *args, **kwargs):
#     def isbound(method):
# def validate_name_args(positional_name, optional_name):
# def validate_cluster_args(positional_cluster, optional_cluster):
# def deprecated(message):
#     def wrapper(func, *args, **kwargs):
# def deprecation_map(dep_map):
#     def _decorator(func):
# def arg(*args, **kwargs):
#     def _decorator(func):
# def env(*args, **kwargs):
# def add_arg(func, *args, **kwargs):
# def unauthenticated(func):
# def isunauthenticated(func):
# def print_list(objs, fields, formatters=None, sortby_index=0,
#                mixed_case_fields=None, field_labels=None):
# def keys_and_vals_to_strs(dictionary):
#     def to_str(k_or_v):
# def print_dict(dct, dict_property="Property", wrap=0):
# def get_password(max_password_prompts=3):
# def service_type(stype):
#     def inner(f):
# def get_service_type(f):
# def pretty_choice_list(lst):
# def exit(msg=''):
# def _format_field_name(attr):
# def make_field_formatter(attr, filters=None):
#     def get_field(obj):
# def _get_list_table_columns_and_formatters(fields, objs, exclude_fields=(),
#                                            filters=None):
# class MissingArgs(Exception):
# class DuplicateArgs(Exception):
# 
# Path: magnumclient/tests/v1/shell_test_base.py
# FAKE_ENV = {'OS_USERNAME': 'username',
#             'OS_PASSWORD': 'password',
#             'OS_PROJECT_NAME': 'project_name',
#             'OS_AUTH_URL': 'http://no.where/v2.0',
#             'BYPASS_URL': 'http://magnum'}
# class TestCommandLineArgument(utils.TestCase):
#     def setUp(self):
#     def _test_arg_success(self, command, keyword=None):
#     def _test_arg_failure(self, command, error_msg):
# 
# Path: magnumclient/v1/certificates_shell.py
# DEPRECATION_MESSAGE = (
#     'WARNING: The bay parameter is deprecated and will be removed in a future '
#     'release.\nUse the cluster parameter to avoid seeing this message.')
# def _show_cert(certificate):
# def _get_target_uuid(cs, args):
# def do_ca_show(cs, args):
# def do_ca_sign(cs, args):
# def do_ca_rotate(cs, args):


from unittest import mock
from magnumclient.common import cliutils
from magnumclient.tests.v1 import shell_test_base
from magnumclient.v1 import certificates_shell

    @mock.patch('magnumclient.v1.clusters.ClusterManager.get')
    @mock.patch('magnumclient.v1.certificates.CertificateManager.get')
    def test_ca_show_failure_with_invalid_field(self, mock_cert_get,
                                                mock_cluster_get):
        self.assertRaises(cliutils.MissingArgs,
                          self._test_arg_failure,
                          'ca-show',
                          self._few_argument_error)
        mock_cert_get.assert_not_called()
        mock_cluster_get.assert_not_called()

    @mock.patch('magnumclient.v1.clusters.ClusterManager.get')
    @mock.patch('magnumclient.v1.certificates.CertificateManager.rotate_ca')
    def test_ca_rotate(self, mock_rotate_ca, mock_cluster_get):
        mockcluster = mock.MagicMock()
        mockcluster.status = "CREATE_COMPLETE"
        mockcluster.uuid = "xxx"
        mock_cluster_get.return_value = mockcluster
        mock_rotate_ca.return_value = None
        self._test_arg_success('ca-rotate '
                               '--cluster xxx')
        expected_args = {}
        expected_args['cluster_uuid'] = mockcluster.uuid
        mock_rotate_ca.assert_called_once_with(**expected_args)

    @mock.patch('magnumclient.v1.clusters.ClusterManager.get')
    @mock.patch('magnumclient.v1.certificates.CertificateManager.rotate_ca')
    def test_ca_rotate_no_cluster_arg(self, mock_rotate_ca, mock_cluster_get):
        _error_msg = [

# Path: magnumclient/common/cliutils.py
# DEPRECATION_BASE = ('%sThe --%s parameter is deprecated and '
#                     'will be removed in a future release. Use the '
#                     '<%s> positional parameter %s.')
# NAME_DEPRECATION_HELP = DEPRECATION_BASE % ('', 'name', 'name', 'instead')
# NAME_DEPRECATION_WARNING = DEPRECATION_BASE % (
#     'WARNING: ', 'name', 'name', 'to avoid seeing this message')
# CLUSTER_DEPRECATION_HELP = DEPRECATION_BASE % ('', 'cluster', 'cluster',
#                                                'instead')
# CLUSTER_DEPRECATION_WARNING = DEPRECATION_BASE % (
#     'WARNING: ', 'cluster', 'cluster', 'to avoid seeing this message')
# MAGNUM_CLIENT_DEPRECATION_WARNING = (
#     'WARNING: The magnum client is deprecated and will be removed in a future '
#     'release.\nUse the OpenStack client to avoid seeing this message.')
# def deprecation_message(preamble, new_name):
#     def __init__(self, missing):
#     def __init__(self, param, dupes):
# def validate_args(fn, *args, **kwargs):
#     def isbound(method):
# def validate_name_args(positional_name, optional_name):
# def validate_cluster_args(positional_cluster, optional_cluster):
# def deprecated(message):
#     def wrapper(func, *args, **kwargs):
# def deprecation_map(dep_map):
#     def _decorator(func):
# def arg(*args, **kwargs):
#     def _decorator(func):
# def env(*args, **kwargs):
# def add_arg(func, *args, **kwargs):
# def unauthenticated(func):
# def isunauthenticated(func):
# def print_list(objs, fields, formatters=None, sortby_index=0,
#                mixed_case_fields=None, field_labels=None):
# def keys_and_vals_to_strs(dictionary):
#     def to_str(k_or_v):
# def print_dict(dct, dict_property="Property", wrap=0):
# def get_password(max_password_prompts=3):
# def service_type(stype):
#     def inner(f):
# def get_service_type(f):
# def pretty_choice_list(lst):
# def exit(msg=''):
# def _format_field_name(attr):
# def make_field_formatter(attr, filters=None):
#     def get_field(obj):
# def _get_list_table_columns_and_formatters(fields, objs, exclude_fields=(),
#                                            filters=None):
# class MissingArgs(Exception):
# class DuplicateArgs(Exception):
# 
# Path: magnumclient/tests/v1/shell_test_base.py
# FAKE_ENV = {'OS_USERNAME': 'username',
#             'OS_PASSWORD': 'password',
#             'OS_PROJECT_NAME': 'project_name',
#             'OS_AUTH_URL': 'http://no.where/v2.0',
#             'BYPASS_URL': 'http://magnum'}
# class TestCommandLineArgument(utils.TestCase):
#     def setUp(self):
#     def _test_arg_success(self, command, keyword=None):
#     def _test_arg_failure(self, command, error_msg):
# 
# Path: magnumclient/v1/certificates_shell.py
# DEPRECATION_MESSAGE = (
#     'WARNING: The bay parameter is deprecated and will be removed in a future '
#     'release.\nUse the cluster parameter to avoid seeing this message.')
# def _show_cert(certificate):
# def _get_target_uuid(cs, args):
# def do_ca_show(cs, args):
# def do_ca_sign(cs, args):
# def do_ca_rotate(cs, args):


# Path: magnumclient/tests/v1/test_certificates_shell.py
from unittest import mock
from magnumclient.common import cliutils
from magnumclient.tests.v1 import shell_test_base
from magnumclient.v1 import certificates_shell


    @mock.patch('magnumclient.v1.clusters.ClusterManager.get')
    @mock.patch('magnumclient.v1.certificates.CertificateManager.get')
    def test_ca_show_failure_with_invalid_field(self, mock_cert_get,
                                                mock_cluster_get):
        self.assertRaises(cliutils.MissingArgs,
                          self._test_arg_failure,
                          'ca-show',
                          self._few_argument_error)
        mock_cert_get.assert_not_called()
        mock_cluster_get.assert_not_called()

    @mock.patch('magnumclient.v1.clusters.ClusterManager.get')
    @mock.patch('magnumclient.v1.certificates.CertificateManager.rotate_ca')
    def test_ca_rotate(self, mock_rotate_ca, mock_cluster_get):
        mockcluster = mock.MagicMock()
        mockcluster.status = "CREATE_COMPLETE"
        mockcluster.uuid = "xxx"
        mock_cluster_get.return_value = mockcluster
        mock_rotate_ca.return_value = None
        self._test_arg_success('ca-rotate '
                               '--cluster xxx')
        expected_args = {}
        expected_args['cluster_uuid'] = mockcluster.uuid
        mock_rotate_ca.assert_called_once_with(**expected_args)

    @mock.patch('magnumclient.v1.clusters.ClusterManager.get')
    @mock.patch('magnumclient.v1.certificates.CertificateManager.rotate_ca')
    def test_ca_rotate_no_cluster_arg(self, mock_rotate_ca, mock_cluster_get):
        _error_msg = [

            (".*(error: argument --cluster is required|"  # py27 compatibility