def test_add_trivial_argument(self): arg_parser = HelpfulArgumentParser(['run'], {}) arg_parser.add(None, "--hello-world") parsed_args = arg_parser.parser.parse_args( ['--hello-world', 'Hello World!']) self.assertIs(parsed_args.hello_world, 'Hello World!') self.assertFalse(hasattr(parsed_args, 'potato'))
def test_parse_args_renew_force_interactive(self): arg_parser = HelpfulArgumentParser(['renew', '--force-interactive'], {}) arg_parser.add(None, constants.FORCE_INTERACTIVE_FLAG, action="store_true") with self.assertRaises(errors.Error): arg_parser.parse_args()
def test_add_expected_argument(self): arg_parser = HelpfulArgumentParser(['--help', 'run'], {}) arg_parser.add([None, "run", "certonly", "register"], "--eab-kid", dest="eab_kid", action="store", metavar="EAB_KID", help="Key Identifier for External Account Binding") parsed_args = arg_parser.parser.parse_args(["--eab-kid", None]) self.assertIsNone(parsed_args.eab_kid) self.assertTrue(hasattr(parsed_args, 'eab_kid'))
def test_parse_args_non_interactive_and_force_interactive(self): arg_parser = HelpfulArgumentParser( ['--force-interactive', '--non-interactive'], {}) arg_parser.add(None, constants.FORCE_INTERACTIVE_FLAG, action="store_true") arg_parser.add(None, "--non-interactive", dest="noninteractive_mode", action="store_true") with self.assertRaises(errors.Error): arg_parser.parse_args()
def test_parse_args_hosts_and_auto_hosts(self): arg_parser = HelpfulArgumentParser(['--hsts', '--auto-hsts'], {}) arg_parser.add(None, "--hsts", action="store_true", dest="hsts") arg_parser.add(None, "--auto-hsts", action="store_true", dest="auto_hsts") # The following arguments are added because they have to be defined # in order for arg_parser to run completely. They are not used for the # test. arg_parser.add(None, constants.FORCE_INTERACTIVE_FLAG, action="store_true") arg_parser.add(None, "--non-interactive", dest="noninteractive_mode", action="store_true") arg_parser.add(None, "--staging") arg_parser.add(None, "--dry-run") arg_parser.add(None, "--csr") arg_parser.add(None, "--must-staple") arg_parser.add(None, "--validate-hooks") arg_parser.add(None, "--allow-subset-of-names") with self.assertRaises(errors.Error): arg_parser.parse_args()
def test_parse_args_subset_names_wildcard_domain(self): arg_parser = HelpfulArgumentParser([ '--domain', '*.example.com,potato.example.com', '--allow-subset-of-names' ], {}) # The following arguments are added because they have to be defined # in order for arg_parser to run completely. They are not used for the # test. arg_parser.add(None, constants.FORCE_INTERACTIVE_FLAG, action="store_true") arg_parser.add(None, "--non-interactive", dest="noninteractive_mode", action="store_true") arg_parser.add(None, "--staging") arg_parser.add(None, "--dry-run") arg_parser.add(None, "--csr") arg_parser.add(None, "--must-staple") arg_parser.add(None, "--validate-hooks") arg_parser.add(None, "-d", "--domain", dest="domains", metavar="DOMAIN", action=_DomainsAction) arg_parser.add(None, "--allow-subset-of-names")