def test_initialize_parse_args(self): args = branch.parse_args( ['initialize', '--milestone', 'MM', '--branch', 'BBBB'], parser_type=ArgumentParser) self.assertEqual(args.milestone, 'MM') self.assertEqual(args.branch, 'BBBB')
def test_initialize_parse_args_fails_when_missing_required_args(self): with self.assertRaises(ParseError) as caught: branch.parse_args(['initialize'], parser_type=ArgumentParser) self.assertEqual( str(caught.exception), 'the following arguments are required: --milestone, --branch')
def test_parse_args_fails_without_subcommand(self): with self.assertRaises(ParseError) as caught: branch.parse_args([], parser_type=ArgumentParser) self.assertEqual(str(caught.exception), 'no sub-command specified')
def test_set_type_parse_args(self): args = branch.parse_args( ['set-type', '--type', 'desktop-extended-stable', '--type', 'cros-lts']) self.assertEqual(args.type, ['desktop-extended-stable', 'cros-lts'])
def test_set_type_parse_args_fails_for_invalid_type(self): with self.assertRaises(ParseError) as caught: branch.parse_args(['set-type', '--type', 'foo'], parser_type=ArgumentParser) self.assertIn("invalid choice: 'foo'", str(caught.exception))
def test_set_type_parse_args(self): args = branch.parse_args(['set-type', '--type', 'lts']) self.assertEqual(args.type, 'lts')