From 7336a176b43989b9d459a2536af88f89e849213f Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 21 Jun 2012 08:20:26 -0400 Subject: Add the version option to all Commands Several Commands were missing the 'version' option. Add it to those that were missing it. Do not remove the version option before calling commands. This means methods such as execute(), forward(), run() receive it. Several of these needed `**options` added to their signatures. Commands in the Cert plugin passed any unknown options to the underlying functions, these are changed to pass what's needed explicitly. Some commands in DNS and Batch plugins now pass version to commands they call. When the option is not given, fill it in automatically. (In a subsequent commit, a warning will be added in this case). Note that the public API did not change: all RPC calls already accepted a version option. There's no need for an API version bump (even though API.txt changes substantially). Design page: http://freeipa.org/page/V3/Messages Tickets: https://fedorahosted.org/freeipa/ticket/2732 https://fedorahosted.org/freeipa/ticket/3294 --- tests/test_ipalib/test_backend.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tests/test_ipalib/test_backend.py') diff --git a/tests/test_ipalib/test_backend.py b/tests/test_ipalib/test_backend.py index b8f8d557..e18c8d38 100644 --- a/tests/test_ipalib/test_backend.py +++ b/tests/test_ipalib/test_backend.py @@ -27,6 +27,7 @@ from tests.data import unicode_str from ipalib.request import context, Connection from ipalib.frontend import Command from ipalib import backend, plugable, errors, base +from ipapython.version import API_VERSION @@ -184,7 +185,7 @@ class test_Executioner(ClassChecker): api.register(echo) class good(Command): - def execute(self): + def execute(self, **options): raise errors.ValidationError( name='nurse', error=u'Not naughty!', @@ -192,7 +193,7 @@ class test_Executioner(ClassChecker): api.register(good) class bad(Command): - def execute(self): + def execute(self, **options): raise ValueError('This is private.') api.register(bad) @@ -224,10 +225,15 @@ class test_Executioner(ClassChecker): arg1 = unicode_str arg2 = (u'Hello', unicode_str, u'world!') args = (arg1,) + arg2 - options = dict(option1=u'How are you?', option2=unicode_str) + options = dict(option1=u'How are you?', option2=unicode_str, + version=API_VERSION) conn = Connection('The connection.', Disconnect('someconn')) context.someconn = conn + print o.execute('echo', arg1, arg2, **options) + print dict( + result=(arg1, arg2, options) + ) assert o.execute('echo', arg1, arg2, **options) == dict( result=(arg1, arg2, options) ) @@ -261,4 +267,6 @@ class test_Executioner(ClassChecker): # Test with option 'name': conn = Connection('The connection.', Disconnect('someconn')) context.someconn = conn - assert o.execute('with_name', name=u'test') == dict(result=u'TEST') + expected = dict(result=u'TEST') + assert expected == o.execute('with_name', name=u'test', + version=API_VERSION) -- cgit