1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
from .common import assert_command, exec_command
def test_default():
returncode, stdout, stderr = exec_command(['dcos'])
assert returncode == 0
assert stdout == """\
Command line utility for the Mesosphere Datacenter Operating
System (DCOS). The Mesosphere DCOS is a distributed operating
system built around Apache Mesos. This utility provides tools
for easy management of a DCOS installation.
Available DCOS commands:
\tconfig \tGet and set DCOS CLI configuration properties
\thelp \tDisplay command line usage information
\tmarathon \tDeploy and manage applications on the DCOS
\tnode \tManage DCOS nodes
\tpackage \tInstall and manage DCOS packages
\tservice \tManage DCOS services
\ttask \tManage DCOS tasks
Get detailed command description with 'dcos <command> --help'.
""".encode('utf-8')
assert stderr == b''
def test_help():
stdout = b"""\
Command line utility for the Mesosphere Datacenter Operating
System (DCOS)
'dcos help' lists all available subcommands. See 'dcos <command> --help'
to read about a specific subcommand.
Usage:
dcos [options] [<command>] [<args>...]
Options:
--help Show this screen
--version Show version
--log-level=<log-level> If set then print supplementary messages to
stderr at or above this level. The severity
levels in the order of severity are: debug,
info, warning, error, and critical. E.g.
Setting the option to warning will print
warning, error and critical messages to stderr.
Note: that this does not affect the output sent
to stdout by the command.
--debug If set then enable further debug messages which
are sent to stdout.
Environment Variables:
DCOS_LOG_LEVEL If set then it specifies that message should be
printed to stderr at or above this level. See
the --log-level option for details.
DCOS_CONFIG This environment variable points to the
location of the DCOS configuration file.
[default: ~/.dcos/dcos.toml]
DCOS_DEBUG If set then enable further debug messages which
are sent to stdout.
DCOS_SSL_VERIFY If set, specifies whether to verify SSL certs
for HTTPS, or the path to the certificate(s).
Can also be configured by setting
`core.ssl_config` in the config.
"""
assert_command(['dcos', '--help'],
stdout=stdout)
def test_version():
assert_command(['dcos', '--version'],
stdout=b'dcos version SNAPSHOT\n')
def test_log_level_flag():
returncode, stdout, stderr = exec_command(
['dcos', '--log-level=info', 'config', '--info'])
assert returncode == 0
assert stdout == b"Get and set DCOS CLI configuration properties\n"
def test_capital_log_level_flag():
returncode, stdout, stderr = exec_command(
['dcos', '--log-level=INFO', 'config', '--info'])
assert returncode == 0
assert stdout == b"Get and set DCOS CLI configuration properties\n"
def test_invalid_log_level_flag():
stdout = (b"Log level set to an unknown value 'blah'. Valid "
b"values are ['debug', 'info', 'warning', 'error', "
b"'critical']\n")
assert_command(
['dcos', '--log-level=blah', 'config', '--info'],
returncode=1,
stdout=stdout)
|