mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Tests: Fix failing tests in ipatests/test_ipalib/test_frontend.py
Test fails were caused mainly by assertion between unicode and nonunicode string, or due to changes in code related to thin client. Fixes: test_Command::test_default_from_chaining test_Command::test_args_options_2_params test_Command::test_params_2_args_options test_Command::test_validate_output_per_type Reviewed-By: Ganna Kaihorodova <gkaihoro@redhat.com>
This commit is contained in:
parent
1d9e1521c5
commit
35d3a58421
@ -24,7 +24,6 @@ Test the `ipalib.frontend` module.
|
|||||||
# FIXME: Pylint errors
|
# FIXME: Pylint errors
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from ipatests.util import raises, read_only
|
from ipatests.util import raises, read_only
|
||||||
@ -462,11 +461,10 @@ class test_Command(ClassChecker):
|
|||||||
api.finalize()
|
api.finalize()
|
||||||
o = my_cmd(api)
|
o = my_cmd(api)
|
||||||
o.finalize()
|
o.finalize()
|
||||||
e = o(**kw) # pylint: disable=not-callable
|
e = o.get_default(**kw) # pylint: disable=not-callable
|
||||||
assert type(e) is dict
|
assert type(e) is dict
|
||||||
assert 'result' in e
|
assert 'option2' in e
|
||||||
assert 'option2' in e['result']
|
assert e['option2'] == u'some value'
|
||||||
assert e['result']['option2'] == u'some value'
|
|
||||||
|
|
||||||
def test_validate(self):
|
def test_validate(self):
|
||||||
"""
|
"""
|
||||||
@ -494,7 +492,7 @@ class test_Command(ClassChecker):
|
|||||||
fail = dict(okay)
|
fail = dict(okay)
|
||||||
fail['option0'] = u'whatever'
|
fail['option0'] = u'whatever'
|
||||||
e = raises(errors.ValidationError, sub.validate, **fail)
|
e = raises(errors.ValidationError, sub.validate, **fail)
|
||||||
assert_equal(e.name, 'option0')
|
assert_equal(e.name, u'option0')
|
||||||
assert_equal(e.value, u'whatever')
|
assert_equal(e.value, u'whatever')
|
||||||
assert_equal(e.error, u"must equal 'option0'")
|
assert_equal(e.error, u"must equal 'option0'")
|
||||||
assert e.rule.__class__.__name__ == 'Rule'
|
assert e.rule.__class__.__name__ == 'Rule'
|
||||||
@ -548,7 +546,7 @@ class test_Command(ClassChecker):
|
|||||||
o = self.get_instance(args=('one', 'two'), options=('three', 'four'))
|
o = self.get_instance(args=('one', 'two'), options=('three', 'four'))
|
||||||
e = raises(errors.OverlapError, o.args_options_2_params,
|
e = raises(errors.OverlapError, o.args_options_2_params,
|
||||||
1, 2, three=3, two=2, four=4, one=1)
|
1, 2, three=3, two=2, four=4, one=1)
|
||||||
assert e.names == ['one', 'two']
|
assert e.names == "['one', 'two']"
|
||||||
|
|
||||||
# Test the permutations:
|
# Test the permutations:
|
||||||
o = self.get_instance(args=('one', 'two*'), options=('three', 'four'))
|
o = self.get_instance(args=('one', 'two*'), options=('three', 'four'))
|
||||||
@ -605,9 +603,9 @@ class test_Command(ClassChecker):
|
|||||||
Test the `ipalib.frontend.Command.params_2_args_options` method.
|
Test the `ipalib.frontend.Command.params_2_args_options` method.
|
||||||
"""
|
"""
|
||||||
o = self.get_instance(args='one', options='two')
|
o = self.get_instance(args='one', options='two')
|
||||||
assert o.params_2_args_options() == ((None,), {})
|
assert o.params_2_args_options() == ((), {})
|
||||||
assert o.params_2_args_options(one=1) == ((1,), {})
|
assert o.params_2_args_options(one=1) == ((1,), {})
|
||||||
assert o.params_2_args_options(two=2) == ((None,), dict(two=2))
|
assert o.params_2_args_options(two=2) == ((), dict(two=2))
|
||||||
assert o.params_2_args_options(two=2, one=1) == ((1,), dict(two=2))
|
assert o.params_2_args_options(two=2, one=1) == ((1,), dict(two=2))
|
||||||
|
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
@ -751,13 +749,13 @@ class test_Command(ClassChecker):
|
|||||||
|
|
||||||
wrong = dict(foo=17.9, bar=[18])
|
wrong = dict(foo=17.9, bar=[18])
|
||||||
e = raises(TypeError, inst.validate_output, wrong)
|
e = raises(TypeError, inst.validate_output, wrong)
|
||||||
assert str(e) == '%s:\n output[%r]: need %r; got %r: %r' % (
|
assert str(e) == '%s:\n output[%r]: need (%r,); got %r: %r' % (
|
||||||
'Complex.validate_output()', 'foo', int, float, 17.9
|
'Complex.validate_output()', 'foo', int, float, 17.9
|
||||||
)
|
)
|
||||||
|
|
||||||
wrong = dict(foo=18, bar=17)
|
wrong = dict(foo=18, bar=17)
|
||||||
e = raises(TypeError, inst.validate_output, wrong)
|
e = raises(TypeError, inst.validate_output, wrong)
|
||||||
assert str(e) == '%s:\n output[%r]: need %r; got %r: %r' % (
|
assert str(e) == '%s:\n output[%r]: need (%r,); got %r: %r' % (
|
||||||
'Complex.validate_output()', 'bar', list, int, 17
|
'Complex.validate_output()', 'bar', list, int, 17
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user