Skip to content

Commit

Permalink
Fixes from comments and last review
Browse files Browse the repository at this point in the history
1. Fixed some text in commands.rst

2. Fixed per comment in generaoptions.rst

3. Added path of connections file to connection list output since we now
have multiple file locations.

4. Cleaned code slightly in conftest.py
  • Loading branch information
KSchopmeyer committed Jul 6, 2020
1 parent 279be57 commit 92811c4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/pywbemcli/cmdshelp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ Help text for ``pywbemcli``:
Enable deprecation warnings. Default: EnvVar PYWBEMCLI_DEPRECATION_WARNINGS, or true.
-C, --connections-file FILE PATH
File path of a YAML file containing named connection definitions. The default if this
option is not specified is /home/kschopmeyer/pywbemcli_connection_definitions.yaml.
EnvVar (PYWBEMCLI_CONNECTIONS_FILE)
option is not specified is the file name "pywbemcli_connection_definitions.yaml" in
the users home directory. EnvVar (PYWBEMCLI_CONNECTIONS_FILE)

--pdb Pause execution in the built-in pdb debugger just before executing the command within
pywbemcli. Default: EnvVar PYWBEMCLI_PDB, or false.
Expand Down
10 changes: 7 additions & 3 deletions docs/pywbemcli/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1360,24 +1360,28 @@ See :ref:`pywbemcli connection export --help` for the exact help output of the c
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``connection list`` command lists the connection definitions in the
:term:`connections file` and also the current connection if it has not been
saved to the connections file.
:term:`connections file` and the current connection(if it has not been
saved to the connections file).

Valid output formats are :term:`Table output formats`.

This shows if a connection is the current connection
This shows which connection is the current connection
and if any connection is set as the default connection (:ref:`Connection select
command` ).

The current connection is marked with `*` in the Name column.
The default connection, if defined, is marked with `#` in the Name column.

The title also displays the path of the file that is being used as the
current connections file.

.. code-block:: text
pywbemcli> --server http://localhost --user me --password mypw --no-verify connection save me
pywbemcli> --server http://blahblah connection list
WBEM server connections(brief): (#: default, *: current)
file: ./pywbemcli_connection_definitions.yaml
+--------------+------------------+----------------------------------------+
| name | server | mock-server |
|--------------+------------------+----------------------------------------|
Expand Down
11 changes: 7 additions & 4 deletions docs/pywbemcli/generaloptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,16 @@ command completion.
.. _`--connections-file general option`:

``--connections-file`` general option
""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""

The ``--connections-file``/``-C`` general option allows the user to select
a file path for the connections file. It is the file path of a YAML file
that defines server configurations by name. The default if this option is
not specified is to use the configuration file
``pywbemcli_connection_definitions.yaml`` defined in the user home directory.
not specified is to use the connections file
``pywbemcli_connection_definitions.yaml`` in the users home directory.

The users home directory is OS dependent. The connection file name is
displayed in the ``connections list`` command

When this option is set, the YAML file defined with the option is used
as the connections file.
Expand All @@ -663,7 +666,7 @@ The connections_file is managed with the commands in the
.. _`--deprecation-warnings general option`:

``--deprecation-warnings`` general option
""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""

The ``--deprecation-warnings``/``--no-deprecation-warnings`` general option is
a boolean option that controls the display of deprecation warnings on the
Expand Down
5 changes: 3 additions & 2 deletions pywbemtools/pywbemcli/_cmd_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ def build_row(options, name, svr):
click.echo(format_table(
sorted(rows),
headers,
title='WBEM server connections({}): ({}: default, {}: current)'.format(
table_type, dflt_sym, cur_sym),
title='WBEM server connections({0}): ({1}: default, {2}: '
'current)\nfile: {3}'.format(
table_type, dflt_sym, cur_sym, connections.connections_file),
table_format=output_format))
10 changes: 8 additions & 2 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
REPO_FILE_BACKUP_PATH = os.path.join(DEFAULT_CONNECTION_FILE_DIR,
DEFAULT_CONNECTIONS_FILE)
# if there is a config file or backup, save to this name during tests
SAVE_FILE = DEFAULT_CONNECTIONS_FILE + '.testsave'
SAVE_FILE_SUFFIX = '.testsave'
SAVE_FILE = DEFAULT_CONNECTIONS_FILE + SAVE_FILE_SUFFIX
SAVE_FILE_PATH = os.path.join(DEFAULT_CONNECTION_FILE_DIR,
SAVE_FILE)

SAVE_BAK_FILE = BACK_FILE + '.testsave'
SAVE_BAK_FILE = BACK_FILE + SAVE_FILE_SUFFIX
SAVE_BAK_FILE_PATH = os.path.join(DEFAULT_CONNECTION_FILE_DIR, SAVE_BAK_FILE)


Expand All @@ -44,6 +45,11 @@ def set_connections_file(request):
This saves and restores any connections file and backup connections file
in the home directory.
This fixture should execute once per session (execution of one of the
test_*.py files) so the load of creating backups and restoring them is
very low. In case the fixture fails to restore the backed up connections
files are saved with with their full names and the suffix `.testsave`.
"""
if os.path.isfile(REPO_FILE_PATH):
os.rename(REPO_FILE_PATH, SAVE_FILE_PATH)
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/test_connection_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,15 +913,15 @@
['Verify connection list with current server from general options, grid',
{'args': ['list'],
'general': ['--output-format', 'table', '--server', 'http://blah']},
{'stdout': """
WBEM server connections(brief): (#: default, *: current)
+------------+-------------+---------------+
| name | server | mock-server |
|------------+-------------+---------------|
| *not-saved | http://blah | |
| svrtest | http://blah | |
+------------+-------------+---------------+
""",
{'stdout': ['WBEM server connections(brief): (#: default, *: current)',
'file:',
'pywbemcli_connection_definitions.yaml',
'+------------+-------------+---------------+',
'| name | server | mock-server |',
'|------------+-------------+---------------|',
'| *not-saved | http://blah | |',
'| svrtest | http://blah | |',
'+------------+-------------+---------------+'],
'test': 'innows',
'file': {'before': 'exists', 'after': 'exists'}},
None, OK],
Expand Down

0 comments on commit 92811c4

Please sign in to comment.