summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2009-02-24 16:47:05 +0100
committerRob Crittenden <rcritten@redhat.com>2009-02-24 14:40:47 -0500
commit8041cd038b77ec9f27ca9836395f9ee7348ca307 (patch)
treee1a5567586f1fad51a55ef7f9ad9d7881567b05b
parent6dae08868f19e7027b90299e4b9495983b266a3d (diff)
downloadfreeipa-8041cd038b77ec9f27ca9836395f9ee7348ca307.tar.gz
freeipa-8041cd038b77ec9f27ca9836395f9ee7348ca307.tar.xz
freeipa-8041cd038b77ec9f27ca9836395f9ee7348ca307.zip
Add unit test for ipalib.frontend.Command.args_options_2_entry.
-rw-r--r--tests/test_ipalib/test_frontend.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/test_ipalib/test_frontend.py b/tests/test_ipalib/test_frontend.py
index 91fc83558..7be94c4fd 100644
--- a/tests/test_ipalib/test_frontend.py
+++ b/tests/test_ipalib/test_frontend.py
@@ -28,7 +28,6 @@ from ipalib.constants import TYPE_ERROR
from ipalib.base import NameSpace
from ipalib import frontend, backend, plugable, errors2, errors, parameters, config
-
def test_RULE_FLAG():
assert frontend.RULE_FLAG == 'validation_rule'
@@ -344,6 +343,38 @@ class test_Command(ClassChecker):
assert mthd(1, (21, 22, 23), three=3, four=4) == \
dict(one=1, two=(21, 22, 23), three=3, four=4)
+ def test_args_options_2_entry(self):
+ """
+ Test `ipalib.frontend.Command.args_options_2_entry` method.
+ """
+ class my_cmd(self.cls):
+ takes_args = (
+ parameters.Str('one', attribute=True),
+ parameters.Str('two', attribute=False),
+ )
+ takes_options = (
+ parameters.Str('three', attribute=True, multivalue=True),
+ parameters.Str('four', attribute=True, multivalue=False),
+ )
+
+ def run(self, *args, **kw):
+ return self.args_options_2_entry(*args, **kw)
+
+ args = ('one', 'two')
+ kw = dict(three=('three1', 'three2'), four='four')
+
+ o = my_cmd()
+ o.finalize()
+ e = o.run(*args, **kw)
+ assert type(e) is dict
+ assert 'one' in e
+ assert 'two' not in e
+ assert 'three' in e
+ assert 'four' in e
+ assert e['one'] == 'one'
+ assert e['three'] == ['three1', 'three2']
+ assert e['four'] == 'four'
+
def test_params_2_args_options(self):
"""
Test the `ipalib.frontend.Command.params_2_args_options` method.