def test_default_options(self, m): name = uuid.uuid4().hex argv = ['--os-auth-plugin', name, '--os-a-float', str(self.a_float)] klass = cli.register_argparse_arguments(self.p, argv) self.assertIs(utils.MockPlugin, klass) opts = self.p.parse_args(argv) self.assertEqual(name, opts.os_auth_plugin) a = cli.load_from_argparse_arguments(opts) self.assertEqual(self.a_float, a['a_float']) self.assertEqual(3, a['a_int'])
def test_param_loading(self, m): name = uuid.uuid4().hex argv = ['--os-auth-plugin', name, '--os-a-int', str(self.a_int), '--os-a-float', str(self.a_float), '--os-a-bool', str(self.a_bool)] klass = cli.register_argparse_arguments(self.p, argv) self.assertIs(utils.MockPlugin, klass) opts = self.p.parse_args(argv) self.assertEqual(name, opts.os_auth_plugin) a = cli.load_from_argparse_arguments(opts) self.assertTestVals(a) self.assertEqual(name, opts.os_auth_plugin) self.assertEqual(str(self.a_int), opts.os_a_int) self.assertEqual(str(self.a_float), opts.os_a_float) self.assertEqual(str(self.a_bool), opts.os_a_bool)
def test_load_with_nothing(self): cli.register_argparse_arguments(self.p, []) opts = self.p.parse_args([]) self.assertIsNone(cli.load_from_argparse_arguments(opts))