def test_build_option_parser(self): """Assert that we don't set default options so that we can load the defaults from the config. """ usage = 'Something' epilog = 'Something' argparse.ArgumentParser = mock.Mock() parser = cmd_utils.build_option_parser( usage=usage, epilog=epilog, ) argparse.ArgumentParser.assert_called_with( usage=usage, formatter_class=argparse.RawDescriptionHelpFormatter, epilog=epilog, ) assert_equal(parser.add_argument.call_count, 4) args = [call[1] for call in parser.add_argument.mock_calls] expected = [ ('--version', ), ('-v', '--verbose'), ('--server', ), ('-s', '--save'), ] assert_equal(args, expected) defaults = [ call[2].get('default') for call in parser.add_argument.mock_calls ] assert_equal(defaults, [None, None, None, None])
def parse_cli(): parser = cmd_utils.build_option_parser() parser.description = ( "Collects metrics from Tron via its API and forwards them to " "meteorite.") parser.add_argument( "--dry-run", action="store_true", default=False, help="Don't actually send metrics out. Defaults: %(default)s") args = parser.parse_args() return args
def parse_cli(): parser = cmd_utils.build_option_parser() parser.add_argument( "--dry-run", action="store_true", default=False, help="Don't actually send alerts out. Defaults to %(default)s", ) parser.add_argument( "--job", default=None, help="Check a particular job. If unset checks all jobs", ) args = parser.parse_args() return args
def test_build_option_parser(self): """Assert that we don't set default options so that we can load the defaults from the config. """ parser_class = mock.Mock() usage = "Something" parser = cmd_utils.build_option_parser(usage, parser_class=parser_class) assert_equal(parser, parser_class.return_value) parser_class.assert_called_with(usage, version="%%prog %s" % tron.__version__) assert_equal(parser.add_option.call_count, 3) options = [call[1] for call in parser.add_option.mock_calls] expected = [("-v", "--verbose"), ("--server",), ("-s", "--save")] assert_equal(options, expected) defaults = [call[2].get("default") for call in parser.add_option.mock_calls] assert_equal(defaults, [None, None, None])
def test_build_option_parser(self): """Assert that we don't set default options so that we can load the defaults from the config. """ parser_class = mock.Mock() usage = 'Something' parser = cmd_utils.build_option_parser(usage, parser_class=parser_class) assert_equal(parser, parser_class.return_value) parser_class.assert_called_with( usage, version="%%prog %s" % tron.__version__) assert_equal(parser.add_option.call_count, 3) options = [call[1] for call in parser.add_option.mock_calls] expected = [('-v', '--verbose'), ('--server',), ('-s', '--save')] assert_equal(options, expected) defaults = [ call[2].get('default') for call in parser.add_option.mock_calls] assert_equal(defaults, [None, None, None])
def parse_cli(): parser = cmd_utils.build_option_parser() parser.add_argument( "--dry-run", action="store_true", default=False, help="Don't actually send alerts out. Defaults to %(default)s", ) parser.add_argument( "--job", default=None, help="Check a particular job. If unset checks all jobs", ) parser.add_argument( "--run-interval", help="Run interval for this monitoring script. This is used to " "calculate realert and alert_after setting. " "Default to %(default)s (seconds)", type=int, dest="run_interval", default=300, ) args = parser.parse_args() return args
def parse_cli(): parser = cmd_utils.build_option_parser() parser.description = ( "Collects metrics from Tron via its API and forwards them to " "meteorite." ) parser.add_argument( "--dry-run", action="store_true", default=False, help="Don't actually send metrics out. Defaults: %(default)s" ) parser.add_argument( "--cluster", default=None, type=str, help=( "Cluster from which these metrics originate. " "Sent as a dimension to meteorite. " "Default: %(default)s" ), ) args = parser.parse_args() return args