Blacken everything else

Black used with the '-l 79 -S' flags.

A future change will ignore this commit in git-blame history by adding a
'git-blame-ignore-revs' file.

Change-Id: I356643d06b2cd408ccaedfe02b858aea55388949
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2023-05-08 11:37:42 +01:00
parent a6f81a736c
commit d3f4a3d7f5
12 changed files with 209 additions and 190 deletions

View File

@ -15,18 +15,19 @@
# -- General configuration ---------------------------------------------------- # -- General configuration ----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0' # needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', extensions = [
'sphinx.ext.doctest', 'sphinx.ext.autodoc',
'sphinx.ext.todo', 'sphinx.ext.doctest',
'openstackdocstheme', 'sphinx.ext.todo',
'stevedore.sphinxext', 'openstackdocstheme',
'cliff.sphinxext', 'stevedore.sphinxext',
'sphinxcontrib.apidoc', 'cliff.sphinxext',
] 'sphinxcontrib.apidoc',
]
# openstackdocstheme options # openstackdocstheme options
openstackdocs_repo_name = 'openstack/python-openstackclient' openstackdocs_repo_name = 'openstack/python-openstackclient'
@ -39,13 +40,13 @@ openstackdocs_projects = [
] ]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
#templates_path = ['_templates'] # templates_path = ['_templates']
# The suffix of source filenames. # The suffix of source filenames.
source_suffix = '.rst' source_suffix = '.rst'
# The encoding of source files. # The encoding of source files.
#source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = 'index'
@ -56,13 +57,13 @@ copyright = '2012-2013 OpenStack Foundation'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
#language = None # language = None
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
#today = '' # today = ''
# Else, today_fmt is used as the format for a strftime call. # Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y' # today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
@ -70,18 +71,18 @@ exclude_patterns = ['**tests**']
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
#default_role = None # default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True # add_function_parentheses = True
# If true, the current module name will be prepended to all description # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
#add_module_names = True # add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
#show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'native' pygments_style = 'native'
@ -94,75 +95,75 @@ modindex_common_prefix = ['openstackclient.']
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
#html_theme_path = ["."] # html_theme_path = ["."]
#html_theme = '_theme' # html_theme = '_theme'
html_theme = 'openstackdocs' html_theme = 'openstackdocs'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the
# documentation. # documentation.
#html_theme_options = {} # html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = [] # html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
#html_title = None # html_title = None
# A shorter title for the navigation bar. Default is the same as html_title. # A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None # html_short_title = None
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # of the sidebar.
#html_logo = None # html_logo = None
# The name of an image file (within the static path) to use as favicon of the # The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
#html_favicon = None # html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static'] # html_static_path = ['_static']
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.
#html_use_smartypants = True # html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # Custom sidebar templates, maps document names to template names.
#html_sidebars = {} # html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.
#html_additional_pages = {} # html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_domain_indices = True # html_domain_indices = True
# If false, no index is generated. # If false, no index is generated.
#html_use_index = True # html_use_index = True
# If true, the index is split into individual pages for each letter. # If true, the index is split into individual pages for each letter.
#html_split_index = False # html_split_index = False
# If true, links to the reST sources are added to the pages. # If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True # html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True # html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True # html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will # If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the # contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served. # base URL from which the finished HTML is served.
#html_use_opensearch = '' # html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml"). # This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None # html_file_suffix = None
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'OpenStackCommandLineClientdoc' htmlhelp_basename = 'OpenStackCommandLineClientdoc'
@ -174,44 +175,46 @@ html_extra_path = ['_extra']
# -- Options for LaTeX output ------------------------------------------------- # -- Options for LaTeX output -------------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper', #'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt',
#'pointsize': '10pt', # Additional stuff for the LaTeX preamble.
#'preamble': '',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]) # (source start file, target name, title, author, documentclass [howto/manual])
# . # .
latex_documents = [ latex_documents = [
('index', 'OpenStackCommandLineClient.tex', (
'OpenStack Command Line Client Documentation', 'index',
'OpenStack', 'manual'), 'OpenStackCommandLineClient.tex',
'OpenStack Command Line Client Documentation',
'OpenStack',
'manual',
),
] ]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
#latex_logo = None # latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts, # For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters. # not chapters.
#latex_use_parts = False # latex_use_parts = False
# If true, show page references after internal links. # If true, show page references after internal links.
#latex_show_pagerefs = False # latex_show_pagerefs = False
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#latex_show_urls = False # latex_show_urls = False
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#latex_appendices = [] # latex_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#latex_domain_indices = True # latex_domain_indices = True
# -- Options for manual page output ------------------------------------------- # -- Options for manual page output -------------------------------------------
@ -229,7 +232,7 @@ man_pages = [
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#man_show_urls = False # man_show_urls = False
# -- Options for Texinfo output ----------------------------------------------- # -- Options for Texinfo output -----------------------------------------------
@ -238,21 +241,25 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
('index', 'OpenStackCommandLineClient', (
'OpenStack Command Line Client Documentation', 'index',
'OpenStack', 'OpenStackCommandLineClient', 'OpenStackCommandLineClient',
'One line description of project.', 'OpenStack Command Line Client Documentation',
'Miscellaneous'), 'OpenStack',
'OpenStackCommandLineClient',
'One line description of project.',
'Miscellaneous',
),
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#texinfo_appendices = [] # texinfo_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#texinfo_domain_indices = True # texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'. # How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote' # texinfo_show_urls = 'footnote'
# -- Options for cliff.sphinxext plugin --------------------------------------- # -- Options for cliff.sphinxext plugin ---------------------------------------
@ -260,8 +267,16 @@ texinfo_documents = [
autoprogram_cliff_application = 'openstack' autoprogram_cliff_application = 'openstack'
autoprogram_cliff_ignored = [ autoprogram_cliff_ignored = [
'--help', '--format', '--column', '--max-width', '--fit-width', '--help',
'--print-empty', '--prefix', '--noindent', '--quote'] '--format',
'--column',
'--max-width',
'--fit-width',
'--print-empty',
'--prefix',
'--noindent',
'--quote',
]
# Prevent cliff from generating "This command is provided by the # Prevent cliff from generating "This command is provided by the
# python-openstackclient plugin." # python-openstackclient plugin."

View File

@ -57,6 +57,7 @@ dump_stack_trace = False
# Generally useful stuff often found in a utils module # Generally useful stuff often found in a utils module
def env(*vars, **kwargs): def env(*vars, **kwargs):
"""Search for the first defined of possibly many env vars """Search for the first defined of possibly many env vars
@ -73,6 +74,7 @@ def env(*vars, **kwargs):
# Common Example functions # Common Example functions
def base_parser(parser): def base_parser(parser):
"""Set up some of the common CLI options """Set up some of the common CLI options
@ -128,7 +130,8 @@ def base_parser(parser):
help="Print API call timing info", help="Print API call timing info",
) )
parser.add_argument( parser.add_argument(
'-v', '--verbose', '-v',
'--verbose',
action='count', action='count',
dest='verbose_level', dest='verbose_level',
default=1, default=1,
@ -225,16 +228,14 @@ def make_session(opts, **kwargs):
) )
auth_p = auth_plugin.load_from_options(**auth_params) auth_p = auth_plugin.load_from_options(**auth_params)
session = ks_session.Session( session = ks_session.Session(auth=auth_p, **kwargs)
auth=auth_p,
**kwargs
)
return session return session
# Top-level functions # Top-level functions
def run(opts): def run(opts):
"""Default run command""" """Default run command"""

View File

@ -31,14 +31,13 @@ DEFAULT_DOMAIN = 'default'
class OpenStackShell(shell.OpenStackShell): class OpenStackShell(shell.OpenStackShell):
def __init__(self): def __init__(self):
super(OpenStackShell, self).__init__( super(OpenStackShell, self).__init__(
description=__doc__.strip(), description=__doc__.strip(),
version=openstackclient.__version__, version=openstackclient.__version__,
command_manager=commandmanager.CommandManager('openstack.cli'), command_manager=commandmanager.CommandManager('openstack.cli'),
deferred_help=True) deferred_help=True,
)
self.api_version = {} self.api_version = {}
@ -51,8 +50,8 @@ class OpenStackShell(shell.OpenStackShell):
def build_option_parser(self, description, version): def build_option_parser(self, description, version):
parser = super(OpenStackShell, self).build_option_parser( parser = super(OpenStackShell, self).build_option_parser(
description, description, version
version) )
parser = clientmanager.build_plugin_option_parser(parser) parser = clientmanager.build_plugin_option_parser(parser)
parser = auth.build_auth_plugins_option_parser(parser) parser = auth.build_auth_plugins_option_parser(parser)
return parser return parser
@ -61,7 +60,7 @@ class OpenStackShell(shell.OpenStackShell):
super(OpenStackShell, self)._final_defaults() super(OpenStackShell, self)._final_defaults()
# Set the default plugin to admin_token if endpoint and token are given # Set the default plugin to admin_token if endpoint and token are given
if (self.options.endpoint and self.options.token): if self.options.endpoint and self.options.token:
# Use token authentication # Use token authentication
self._auth_type = 'admin_token' self._auth_type = 'admin_token'
else: else:
@ -96,10 +95,12 @@ class OpenStackShell(shell.OpenStackShell):
if version_opt not in mod_versions: if version_opt not in mod_versions:
sorted_versions = sorted( sorted_versions = sorted(
mod.API_VERSIONS.keys(), mod.API_VERSIONS.keys(),
key=lambda s: list(map(int, s.split('.')))) key=lambda s: list(map(int, s.split('.'))),
)
self.log.warning( self.log.warning(
"%s version %s is not in supported versions: %s" "%s version %s is not in supported versions: %s"
% (api, version_opt, ', '.join(sorted_versions))) % (api, version_opt, ', '.join(sorted_versions))
)
# Command groups deal only with major versions # Command groups deal only with major versions
version = '.v' + version_opt.replace('.', '_').split('_')[0] version = '.v' + version_opt.replace('.', '_').split('_')[0]
@ -107,7 +108,7 @@ class OpenStackShell(shell.OpenStackShell):
self.command_manager.add_command_group(cmd_group) self.command_manager.add_command_group(cmd_group)
self.log.debug( self.log.debug(
'%(name)s API version %(version)s, cmd group %(group)s', '%(name)s API version %(version)s, cmd group %(group)s',
{'name': api, 'version': version_opt, 'group': cmd_group} {'name': api, 'version': version_opt, 'group': cmd_group},
) )
def _load_commands(self): def _load_commands(self):
@ -116,8 +117,7 @@ class OpenStackShell(shell.OpenStackShell):
osc-lib has no opinion on what commands should be loaded osc-lib has no opinion on what commands should be loaded
""" """
# Commands that span multiple APIs # Commands that span multiple APIs
self.command_manager.add_command_group( self.command_manager.add_command_group('openstack.common')
'openstack.common')
# This is the naive extension implementation referred to in # This is the naive extension implementation referred to in
# blueprint 'client-extensions' # blueprint 'client-extensions'
@ -129,8 +129,7 @@ class OpenStackShell(shell.OpenStackShell):
# 'show_repo=qaz.github.repo:ShowRepo', # 'show_repo=qaz.github.repo:ShowRepo',
# ], # ],
# } # }
self.command_manager.add_command_group( self.command_manager.add_command_group('openstack.extension')
'openstack.extension')
def initialize_app(self, argv): def initialize_app(self, argv):
super(OpenStackShell, self).initialize_app(argv) super(OpenStackShell, self).initialize_app(argv)

View File

@ -40,14 +40,16 @@ def execute(cmd, fail_ok=False, merge_stderr=False):
if not fail_ok and proc.returncode != 0: if not fail_ok and proc.returncode != 0:
raise exceptions.CommandFailed( raise exceptions.CommandFailed(
proc.returncode, cmd, result_out, result_err, proc.returncode,
cmd,
result_out,
result_err,
) )
return result_out return result_out
class TestCase(testtools.TestCase): class TestCase(testtools.TestCase):
@classmethod @classmethod
def openstack( def openstack(
cls, cls,
@ -128,8 +130,9 @@ class TestCase(testtools.TestCase):
@classmethod @classmethod
def get_opts(cls, fields, output_format='value'): def get_opts(cls, fields, output_format='value'):
return ' -f {0} {1}'.format(output_format, return ' -f {0} {1}'.format(
' '.join(['-c ' + it for it in fields])) output_format, ' '.join(['-c ' + it for it in fields])
)
@classmethod @classmethod
def assertOutput(cls, expected, actual): def assertOutput(cls, expected, actual):

View File

@ -29,8 +29,7 @@ REGION_NAME = "richie"
INTERFACE = "catchy" INTERFACE = "catchy"
VERSION = "3" VERSION = "3"
TEST_RESPONSE_DICT = fixture.V2Token(token_id=AUTH_TOKEN, TEST_RESPONSE_DICT = fixture.V2Token(token_id=AUTH_TOKEN, user_name=USERNAME)
user_name=USERNAME)
_s = TEST_RESPONSE_DICT.add_service('identity', name='keystone') _s = TEST_RESPONSE_DICT.add_service('identity', name='keystone')
_s.add_endpoint(AUTH_URL + ':5000/v2.0') _s.add_endpoint(AUTH_URL + ':5000/v2.0')
_s = TEST_RESPONSE_DICT.add_service('network', name='neutron') _s = TEST_RESPONSE_DICT.add_service('network', name='neutron')
@ -49,7 +48,6 @@ TEST_VERSIONS = fixture.DiscoveryList(href=AUTH_URL)
class FakeStdout(object): class FakeStdout(object):
def __init__(self): def __init__(self):
self.content = [] self.content = []
@ -64,7 +62,6 @@ class FakeStdout(object):
class FakeLog(object): class FakeLog(object):
def __init__(self): def __init__(self):
self.messages = {} self.messages = {}
@ -85,7 +82,6 @@ class FakeLog(object):
class FakeApp(object): class FakeApp(object):
def __init__(self, _stdout, _log): def __init__(self, _stdout, _log):
self.stdout = _stdout self.stdout = _stdout
self.client_manager = None self.client_manager = None
@ -102,7 +98,6 @@ class FakeOptions(object):
class FakeClient(object): class FakeClient(object):
def __init__(self, **kwargs): def __init__(self, **kwargs):
self.endpoint = kwargs['endpoint'] self.endpoint = kwargs['endpoint']
self.token = kwargs['token'] self.token = kwargs['token']
@ -131,7 +126,6 @@ class FakeClientManager(object):
self.configuration_type = 'cloud_config' self.configuration_type = 'cloud_config'
def get_configuration(self): def get_configuration(self):
config = { config = {
'region': REGION_NAME, 'region': REGION_NAME,
'identity_api_version': VERSION, 'identity_api_version': VERSION,
@ -161,7 +155,6 @@ class FakeClientManager(object):
class FakeModule(object): class FakeModule(object):
def __init__(self, name, version): def __init__(self, name, version):
self.name = name self.name = name
self.__version__ = version self.__version__ = version
@ -171,7 +164,6 @@ class FakeModule(object):
class FakeResource(object): class FakeResource(object):
def __init__(self, manager=None, info=None, loaded=False, methods=None): def __init__(self, manager=None, info=None, loaded=False, methods=None):
"""Set attributes and methods for a resource. """Set attributes and methods for a resource.
@ -195,7 +187,7 @@ class FakeResource(object):
self._loaded = loaded self._loaded = loaded
def _add_details(self, info): def _add_details(self, info):
for (k, v) in info.items(): for k, v in info.items():
setattr(self, k, v) setattr(self, k, v)
def _add_methods(self, methods): def _add_methods(self, methods):
@ -206,13 +198,14 @@ class FakeResource(object):
@value. When users access the attribute with (), @value will be @value. When users access the attribute with (), @value will be
returned, which looks like a function call. returned, which looks like a function call.
""" """
for (name, ret) in methods.items(): for name, ret in methods.items():
method = mock.Mock(return_value=ret) method = mock.Mock(return_value=ret)
setattr(self, name, method) setattr(self, name, method)
def __repr__(self): def __repr__(self):
reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_' and reprkeys = sorted(
k != 'manager') k for k in self.__dict__.keys() if k[0] != '_' and k != 'manager'
)
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys) info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
return "<%s %s>" % (self.__class__.__name__, info) return "<%s %s>" % (self.__class__.__name__, info)
@ -237,9 +230,9 @@ class FakeResource(object):
class FakeResponse(requests.Response): class FakeResponse(requests.Response):
def __init__(
def __init__(self, headers=None, status_code=200, self, headers=None, status_code=200, data=None, encoding=None
data=None, encoding=None): ):
super(FakeResponse, self).__init__() super(FakeResponse, self).__init__()
headers = headers or {} headers = headers or {}
@ -253,7 +246,6 @@ class FakeResponse(requests.Response):
class FakeModel(dict): class FakeModel(dict):
def __getattr__(self, key): def __getattr__(self, key):
try: try:
return self[key] return self[key]

View File

@ -51,15 +51,19 @@ V3_VERSION_RESP = {
"version": { "version": {
"status": "stable", "status": "stable",
"updated": "2016-04-04T00:00:00Z", "updated": "2016-04-04T00:00:00Z",
"media-types": [{ "media-types": [
"base": "application/json", {
"type": "application/vnd.openstack.identity-v3+json", "base": "application/json",
}], "type": "application/vnd.openstack.identity-v3+json",
}
],
"id": "v3.6", "id": "v3.6",
"links": [{ "links": [
"href": V3_AUTH_URL, {
"rel": "self", "href": V3_AUTH_URL,
}] "rel": "self",
}
],
} }
} }
@ -114,7 +118,6 @@ def make_v3_token(req_mock):
class TestInteg(utils.TestCase): class TestInteg(utils.TestCase):
def setUp(self): def setUp(self):
super(TestInteg, self).setUp() super(TestInteg, self).setUp()

View File

@ -20,7 +20,6 @@ from openstackclient.tests.unit import test_shell
class TestIntegV2ProjectID(test_base.TestInteg): class TestIntegV2ProjectID(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegV2ProjectID, self).setUp() super(TestIntegV2ProjectID, self).setUp()
env = { env = {
@ -78,7 +77,6 @@ class TestIntegV2ProjectID(test_base.TestInteg):
class TestIntegV2ProjectName(test_base.TestInteg): class TestIntegV2ProjectName(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegV2ProjectName, self).setUp() super(TestIntegV2ProjectName, self).setUp()
env = { env = {
@ -136,7 +134,6 @@ class TestIntegV2ProjectName(test_base.TestInteg):
class TestIntegV3ProjectID(test_base.TestInteg): class TestIntegV3ProjectID(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegV3ProjectID, self).setUp() super(TestIntegV3ProjectID, self).setUp()
env = { env = {
@ -192,7 +189,6 @@ class TestIntegV3ProjectID(test_base.TestInteg):
class TestIntegV3ProjectName(test_base.TestInteg): class TestIntegV3ProjectName(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegV3ProjectName, self).setUp() super(TestIntegV3ProjectName, self).setUp()
env = { env = {

View File

@ -22,7 +22,6 @@ from openstackclient.tests.unit import test_shell
class TestIntegShellCliNoAuth(test_base.TestInteg): class TestIntegShellCliNoAuth(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegShellCliNoAuth, self).setUp() super(TestIntegShellCliNoAuth, self).setUp()
env = {} env = {}
@ -67,7 +66,6 @@ class TestIntegShellCliNoAuth(test_base.TestInteg):
class TestIntegShellCliV2(test_base.TestInteg): class TestIntegShellCliV2(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegShellCliV2, self).setUp() super(TestIntegShellCliV2, self).setUp()
env = { env = {
@ -155,7 +153,6 @@ class TestIntegShellCliV2(test_base.TestInteg):
class TestIntegShellCliV2Ignore(test_base.TestInteg): class TestIntegShellCliV2Ignore(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegShellCliV2Ignore, self).setUp() super(TestIntegShellCliV2Ignore, self).setUp()
env = { env = {
@ -202,7 +199,6 @@ class TestIntegShellCliV2Ignore(test_base.TestInteg):
class TestIntegShellCliV3(test_base.TestInteg): class TestIntegShellCliV3(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegShellCliV3, self).setUp() super(TestIntegShellCliV3, self).setUp()
env = { env = {
@ -293,7 +289,6 @@ class TestIntegShellCliV3(test_base.TestInteg):
class TestIntegShellCliV3Prompt(test_base.TestInteg): class TestIntegShellCliV3Prompt(test_base.TestInteg):
def setUp(self): def setUp(self):
super(TestIntegShellCliV3Prompt, self).setUp() super(TestIntegShellCliV3Prompt, self).setUp()
env = { env = {
@ -318,8 +313,7 @@ class TestIntegShellCliV3Prompt(test_base.TestInteg):
# Check password callback set correctly # Check password callback set correctly
self.assertEqual( self.assertEqual(
mock_prompt, mock_prompt, _shell.cloud._openstack_config._pw_callback
_shell.cloud._openstack_config._pw_callback
) )
# Check auth request # Check auth request
@ -358,8 +352,9 @@ class TestIntegShellCliPrecedence(test_base.TestInteg):
self.token = test_base.make_v3_token(self.requests_mock) self.token = test_base.make_v3_token(self.requests_mock)
# Patch a v3 auth URL into the o-c-c data # Patch a v3 auth URL into the o-c-c data
test_shell.PUBLIC_1['public-clouds']['megadodo']['auth']['auth_url'] \ test_shell.PUBLIC_1['public-clouds']['megadodo']['auth'][
= test_base.V3_AUTH_URL 'auth_url'
] = test_base.V3_AUTH_URL
def test_shell_args_options(self): def test_shell_args_options(self):
"""Verify command line options override environment variables""" """Verify command line options override environment variables"""
@ -432,8 +427,9 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg):
self.token = test_base.make_v3_token(self.requests_mock) self.token = test_base.make_v3_token(self.requests_mock)
# Patch a v3 auth URL into the o-c-c data # Patch a v3 auth URL into the o-c-c data
test_shell.PUBLIC_1['public-clouds']['megadodo']['auth']['auth_url'] \ test_shell.PUBLIC_1['public-clouds']['megadodo']['auth'][
= test_base.V3_AUTH_URL 'auth_url'
] = test_base.V3_AUTH_URL
def get_temp_file_path(self, filename): def get_temp_file_path(self, filename):
"""Returns an absolute path for a temporary file. """Returns an absolute path for a temporary file.
@ -457,10 +453,12 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg):
log_file = self.get_temp_file_path('test_log_file') log_file = self.get_temp_file_path('test_log_file')
cloud2 = test_shell.get_cloud(log_file) cloud2 = test_shell.get_cloud(log_file)
return ('file.yaml', cloud2) return ('file.yaml', cloud2)
config_mock.side_effect = config_mock_return config_mock.side_effect = config_mock_return
def vendor_mock_return(): def vendor_mock_return():
return ('file.yaml', copy.deepcopy(test_shell.PUBLIC_1)) return ('file.yaml', copy.deepcopy(test_shell.PUBLIC_1))
vendor_mock.side_effect = vendor_mock_return vendor_mock.side_effect = vendor_mock_return
_shell = shell.OpenStackShell() _shell = shell.OpenStackShell()
@ -528,10 +526,12 @@ class TestIntegShellCliPrecedenceOCC(test_base.TestInteg):
log_file = self.get_temp_file_path('test_log_file') log_file = self.get_temp_file_path('test_log_file')
cloud2 = test_shell.get_cloud(log_file) cloud2 = test_shell.get_cloud(log_file)
return ('file.yaml', cloud2) return ('file.yaml', cloud2)
config_mock.side_effect = config_mock_return config_mock.side_effect = config_mock_return
def vendor_mock_return(): def vendor_mock_return():
return ('file.yaml', copy.deepcopy(test_shell.PUBLIC_1)) return ('file.yaml', copy.deepcopy(test_shell.PUBLIC_1))
vendor_mock.side_effect = vendor_mock_return vendor_mock.side_effect = vendor_mock_return
_shell = shell.OpenStackShell() _shell = shell.OpenStackShell()

View File

@ -96,7 +96,7 @@ global_options = {
'--os-cacert': ('/dev/null', True, True), '--os-cacert': ('/dev/null', True, True),
'--timing': (True, True, False), '--timing': (True, True, False),
'--os-profile': ('SECRET_KEY', True, False), '--os-profile': ('SECRET_KEY', True, False),
'--os-interface': (DEFAULT_INTERFACE, True, True) '--os-interface': (DEFAULT_INTERFACE, True, True),
} }
@ -138,7 +138,6 @@ wrapt.wrap_function_wrapper(
class TestShell(osc_lib_test_utils.TestShell): class TestShell(osc_lib_test_utils.TestShell):
# Full name of the OpenStackShell class to test (cliff.app.App subclass) # Full name of the OpenStackShell class to test (cliff.app.App subclass)
shell_class_name = "openstackclient.shell.OpenStackShell" shell_class_name = "openstackclient.shell.OpenStackShell"
@ -179,8 +178,8 @@ class TestShell(osc_lib_test_utils.TestShell):
def _assert_token_auth(self, cmd_options, default_args): def _assert_token_auth(self, cmd_options, default_args):
with mock.patch( with mock.patch(
self.app_patch + ".initialize_app", self.app_patch + ".initialize_app",
self.app, self.app,
): ):
_shell = osc_lib_test_utils.make_shell( _shell = osc_lib_test_utils.make_shell(
shell_class=self.shell_class, shell_class=self.shell_class,
@ -191,20 +190,18 @@ class TestShell(osc_lib_test_utils.TestShell):
self.app.assert_called_with(["list", "role"]) self.app.assert_called_with(["list", "role"])
self.assertEqual( self.assertEqual(
default_args.get("token", ''), default_args.get("token", ''), _shell.options.token, "token"
_shell.options.token,
"token"
) )
self.assertEqual( self.assertEqual(
default_args.get("auth_url", ''), default_args.get("auth_url", ''),
_shell.options.auth_url, _shell.options.auth_url,
"auth_url" "auth_url",
) )
def _assert_cli(self, cmd_options, default_args): def _assert_cli(self, cmd_options, default_args):
with mock.patch( with mock.patch(
self.shell_class_name + ".initialize_app", self.shell_class_name + ".initialize_app",
self.app, self.app,
): ):
_shell = osc_lib_test_utils.make_shell( _shell = osc_lib_test_utils.make_shell(
shell_class=self.shell_class, shell_class=self.shell_class,
@ -213,20 +210,29 @@ class TestShell(osc_lib_test_utils.TestShell):
osc_lib_test_utils.fake_execute(_shell, _cmd) osc_lib_test_utils.fake_execute(_shell, _cmd)
self.app.assert_called_with(["list", "server"]) self.app.assert_called_with(["list", "server"])
self.assertEqual(default_args["compute_api_version"], self.assertEqual(
_shell.options.os_compute_api_version) default_args["compute_api_version"],
self.assertEqual(default_args["identity_api_version"], _shell.options.os_compute_api_version,
_shell.options.os_identity_api_version) )
self.assertEqual(default_args["image_api_version"], self.assertEqual(
_shell.options.os_image_api_version) default_args["identity_api_version"],
self.assertEqual(default_args["volume_api_version"], _shell.options.os_identity_api_version,
_shell.options.os_volume_api_version) )
self.assertEqual(default_args["network_api_version"], self.assertEqual(
_shell.options.os_network_api_version) default_args["image_api_version"],
_shell.options.os_image_api_version,
)
self.assertEqual(
default_args["volume_api_version"],
_shell.options.os_volume_api_version,
)
self.assertEqual(
default_args["network_api_version"],
_shell.options.os_network_api_version,
)
class TestShellOptions(TestShell): class TestShellOptions(TestShell):
def setUp(self): def setUp(self):
super(TestShellOptions, self).setUp() super(TestShellOptions, self).setUp()
self.useFixture(osc_lib_test_utils.EnvFixture()) self.useFixture(osc_lib_test_utils.EnvFixture())
@ -289,7 +295,6 @@ class TestShellOptions(TestShell):
class TestShellTokenAuthEnv(TestShell): class TestShellTokenAuthEnv(TestShell):
def setUp(self): def setUp(self):
super(TestShellTokenAuthEnv, self).setUp() super(TestShellTokenAuthEnv, self).setUp()
env = { env = {
@ -333,7 +338,6 @@ class TestShellTokenAuthEnv(TestShell):
class TestShellTokenEndpointAuthEnv(TestShell): class TestShellTokenEndpointAuthEnv(TestShell):
def setUp(self): def setUp(self):
super(TestShellTokenEndpointAuthEnv, self).setUp() super(TestShellTokenEndpointAuthEnv, self).setUp()
env = { env = {
@ -377,7 +381,6 @@ class TestShellTokenEndpointAuthEnv(TestShell):
class TestShellCli(TestShell): class TestShellCli(TestShell):
def setUp(self): def setUp(self):
super(TestShellCli, self).setUp() super(TestShellCli, self).setUp()
env = { env = {
@ -408,6 +411,6 @@ class TestShellCli(TestShell):
"identity_api_version": LIB_IDENTITY_API_VERSION, "identity_api_version": LIB_IDENTITY_API_VERSION,
"image_api_version": LIB_IMAGE_API_VERSION, "image_api_version": LIB_IMAGE_API_VERSION,
"volume_api_version": LIB_VOLUME_API_VERSION, "volume_api_version": LIB_VOLUME_API_VERSION,
"network_api_version": LIB_NETWORK_API_VERSION "network_api_version": LIB_NETWORK_API_VERSION,
} }
self._assert_cli(flag, kwargs) self._assert_cli(flag, kwargs)

View File

@ -29,22 +29,26 @@ class ParserException(Exception):
class CompareBySet(list): class CompareBySet(list):
"""Class to compare value using set.""" """Class to compare value using set."""
def __eq__(self, other): def __eq__(self, other):
return set(self) == set(other) return set(self) == set(other)
class TestCase(testtools.TestCase): class TestCase(testtools.TestCase):
def setUp(self): def setUp(self):
testtools.TestCase.setUp(self) testtools.TestCase.setUp(self)
if (os.environ.get("OS_STDOUT_CAPTURE") == "True" or if (
os.environ.get("OS_STDOUT_CAPTURE") == "1"): os.environ.get("OS_STDOUT_CAPTURE") == "True"
or os.environ.get("OS_STDOUT_CAPTURE") == "1"
):
stdout = self.useFixture(fixtures.StringStream("stdout")).stream stdout = self.useFixture(fixtures.StringStream("stdout")).stream
self.useFixture(fixtures.MonkeyPatch("sys.stdout", stdout)) self.useFixture(fixtures.MonkeyPatch("sys.stdout", stdout))
if (os.environ.get("OS_STDERR_CAPTURE") == "True" or if (
os.environ.get("OS_STDERR_CAPTURE") == "1"): os.environ.get("OS_STDERR_CAPTURE") == "True"
or os.environ.get("OS_STDERR_CAPTURE") == "1"
):
stderr = self.useFixture(fixtures.StringStream("stderr")).stream stderr = self.useFixture(fixtures.StringStream("stderr")).stream
self.useFixture(fixtures.MonkeyPatch("sys.stderr", stderr)) self.useFixture(fixtures.MonkeyPatch("sys.stderr", stderr))
@ -76,8 +80,9 @@ class TestCommand(TestCase):
try: try:
parsed_args = cmd_parser.parse_args(args) parsed_args = cmd_parser.parse_args(args)
except SystemExit: except SystemExit:
raise ParserException("Argument parse failed: %s" % raise ParserException(
stderr.getvalue()) "Argument parse failed: %s" % stderr.getvalue()
)
for av in verify_args: for av in verify_args:
attr, value = av attr, value = av
if attr: if attr:

View File

@ -43,7 +43,7 @@ from sphinx.util import logging
# https://github.com/sphinx-doc/sphinx/issues/10112 this may be applied as a # https://github.com/sphinx-doc/sphinx/issues/10112 this may be applied as a
# dirty hack until the issue with replacing extlinks is resolved # dirty hack until the issue with replacing extlinks is resolved
linklogger = logging.getLogger('sphinx.ext.extlinks') linklogger = logging.getLogger('sphinx.ext.extlinks')
linklogger.setLevel(40) # Ignore messages less severe than ERROR linklogger.setLevel(40) # Ignore messages less severe than ERROR
extensions = [ extensions = [
'openstackdocstheme', 'openstackdocstheme',
@ -224,10 +224,8 @@ htmlhelp_basename = 'OpenStackClientReleaseNotesdoc'
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper', # 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt', # 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
# 'preamble': '', # 'preamble': '',
} }
@ -235,13 +233,15 @@ latex_elements = {
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [( latex_documents = [
'index', (
'OpenStackClientReleaseNotes.tex', 'index',
'OpenStackClient Release Notes Documentation', 'OpenStackClientReleaseNotes.tex',
'OpenStackClient Developers', 'OpenStackClient Release Notes Documentation',
'manual', 'OpenStackClient Developers',
)] 'manual',
)
]
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
@ -268,13 +268,15 @@ latex_documents = [(
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [( man_pages = [
'index', (
'openstackclientreleasenotes', 'index',
'OpenStackClient Release Notes Documentation', 'openstackclientreleasenotes',
['OpenStackClient Developers'], 'OpenStackClient Release Notes Documentation',
1, ['OpenStackClient Developers'],
)] 1,
)
]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
# man_show_urls = False # man_show_urls = False
@ -285,15 +287,17 @@ man_pages = [(
# Grouping the document tree into Texinfo files. List of tuples # Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [( texinfo_documents = [
'index', (
'OpenStackClientReleaseNotes', 'index',
'OpenStackclient Release Notes Documentation', 'OpenStackClientReleaseNotes',
'OpenStackclient Developers', 'OpenStackclient Release Notes Documentation',
'OpenStackClientReleaseNotes', 'OpenStackclient Developers',
'A unified command-line client for OpenStack.', 'OpenStackClientReleaseNotes',
'Miscellaneous', 'A unified command-line client for OpenStack.',
)] 'Miscellaneous',
)
]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
# texinfo_appendices = [] # texinfo_appendices = []

View File

@ -15,6 +15,4 @@
import setuptools import setuptools
setuptools.setup( setuptools.setup(setup_requires=['pbr>=2.0.0'], pbr=True)
setup_requires=['pbr>=2.0.0'],
pbr=True)