summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-02-22 14:29:26 -0500
committerRob Crittenden <rcritten@redhat.com>2010-02-26 12:31:11 -0500
commit766757e4d4d57c0dad881c1176ae318462203adc (patch)
treeaf1d917b1bba0db7f4405e5c7767d80b6fa1afa0
parent0700f4d7cae9b0b25214b117715dd91a6ccb1132 (diff)
downloadfreeipa-766757e4d4d57c0dad881c1176ae318462203adc.tar.gz
freeipa-766757e4d4d57c0dad881c1176ae318462203adc.tar.xz
freeipa-766757e4d4d57c0dad881c1176ae318462203adc.zip
Fix unicode failures in Env tests and dn failures in XML-RPC tests
-rw-r--r--ipalib/__init__.py2
-rw-r--r--ipalib/config.py16
-rw-r--r--ipalib/frontend.py2
-rw-r--r--tests/test_ipalib/test_config.py38
-rw-r--r--tests/test_xmlrpc/test_group_plugin.py14
-rw-r--r--tests/test_xmlrpc/test_host_plugin.py3
-rw-r--r--tests/test_xmlrpc/test_hostgroup_plugin.py2
-rw-r--r--tests/test_xmlrpc/test_rolegroup_plugin.py12
-rw-r--r--tests/test_xmlrpc/test_taskgroup_plugin.py12
-rw-r--r--tests/test_xmlrpc/test_user_plugin.py8
10 files changed, 55 insertions, 54 deletions
diff --git a/ipalib/__init__.py b/ipalib/__init__.py
index beaf0ab5..51b63c9f 100644
--- a/ipalib/__init__.py
+++ b/ipalib/__init__.py
@@ -754,7 +754,7 @@ For example:
>>> api.register(motd)
>>> api.finalize()
>>> api.Command.motd()
-{'result': 'Hello, world!'}
+{'result': u'Hello, world!'}
Also see the `plugable.API.bootstrap_with_global_options()` method.
diff --git a/ipalib/config.py b/ipalib/config.py
index 8597645a..1dbd5b7c 100644
--- a/ipalib/config.py
+++ b/ipalib/config.py
@@ -54,17 +54,17 @@ class Env(object):
>>> env = Env()
>>> env.attr = 'I was set as an attribute.'
>>> env.attr
- 'I was set as an attribute.'
+ u'I was set as an attribute.'
>>> env['attr'] # Also retrieve as a dictionary item
- 'I was set as an attribute.'
+ u'I was set as an attribute.'
Or you can set a variable as a dictionary item:
>>> env['item'] = 'I was set as a dictionary item.'
>>> env['item']
- 'I was set as a dictionary item.'
+ u'I was set as a dictionary item.'
>>> env.item # Also retrieve as an attribute
- 'I was set as a dictionary item.'
+ u'I was set as a dictionary item.'
The variable names must be valid lower-case Python identifiers that neither
start nor end with an underscore. If your variable name doesn't meet these
@@ -101,7 +101,7 @@ class Env(object):
>>> env.not_false = 'false' # Not equal to repr(False)!
>>> env.not_false
- 'false'
+ u'false'
If an ``str`` value looks like an integer, it's automatically converted to
the ``int`` type. Likewise, if an ``str`` value looks like a floating-point
@@ -119,7 +119,7 @@ class Env(object):
>>> env.message = ' Hello! ' # Surrounded by double spaces
>>> env.message
- 'Hello!'
+ u'Hello!'
>>> env.number = ' 42 ' # Still converted to an int
>>> env.number
42
@@ -140,7 +140,7 @@ class Env(object):
>>> env.date = 'Second'
Traceback (most recent call last):
...
- AttributeError: cannot override Env.date value 'First' with 'Second'
+ AttributeError: cannot override Env.date value u'First' with 'Second'
An `Env` instance can be *locked*, after which no further variables can be
set. Trying to set variables on a locked `Env` instance will also raise
@@ -400,7 +400,7 @@ class Env(object):
>>> env = Env()
>>> env.home = '/people/joe'
>>> env._join('home', 'Music', 'favourites')
- '/people/joe/Music/favourites'
+ u'/people/joe/Music/favourites'
"""
if key in self and self[key] is not None:
return path.join(self[key], *parts)
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 4d0df3a5..e3828bf8 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -301,7 +301,7 @@ class HasParam(Plugin):
>>> bar = Env(context='bar')
>>> another = Env(context='another')
>>> (foo.context, bar.context, another.context)
- ('foo', 'bar', 'another')
+ (u'foo', u'bar', u'another')
>>> list(eg._filter_param_by_context('args', foo))
[Str('foo_only', include=['foo']), Str('not_bar', exclude=['bar']), Str('both')]
>>> list(eg._filter_param_by_context('args', bar))
diff --git a/tests/test_ipalib/test_config.py b/tests/test_ipalib/test_config.py
index fc2f81c9..d1ca55d4 100644
--- a/tests/test_ipalib/test_config.py
+++ b/tests/test_ipalib/test_config.py
@@ -39,8 +39,8 @@ from ipalib import config, constants, base
# raw: the value being set (possibly a string repr)
# value: the expected value after the lightweight conversion
good_vars = (
- ('a_string', 'Hello world!', 'Hello world!'),
- ('trailing_whitespace', ' value ', 'value'),
+ ('a_string', u'Hello world!', u'Hello world!'),
+ ('trailing_whitespace', u' value ', u'value'),
('an_int', 42, 42),
('int_repr', ' 42 ', 42),
('a_float', 3.14, 3.14),
@@ -54,16 +54,16 @@ good_vars = (
('empty', '', None),
# These verify that the implied conversion is case-sensitive:
- ('not_true', ' true ', 'true'),
- ('not_false', ' false ', 'false'),
- ('not_none', ' none ', 'none'),
+ ('not_true', u' true ', u'true'),
+ ('not_false', u' false ', u'false'),
+ ('not_none', u' none ', u'none'),
)
bad_names = (
- ('CamelCase', 'value'),
- ('_leading_underscore', 'value'),
- ('trailing_underscore_', 'value'),
+ ('CamelCase', u'value'),
+ ('_leading_underscore', u'value'),
+ ('trailing_underscore_', u'value'),
)
@@ -253,7 +253,7 @@ class test_Env(ClassChecker):
Test the `ipalib.config.Env.__getitem__` method.
"""
o = self.cls()
- value = 'some value'
+ value = u'some value'
o.key = value
assert o.key is value
assert o['key'] is value
@@ -300,7 +300,7 @@ class test_Env(ClassChecker):
assert len(o) == 0
for i in xrange(1, 11):
key = 'key%d' % i
- value = 'value %d' % i
+ value = u'value %d' % i
o[key] = value
assert o[key] is value
assert len(o) == i
@@ -321,16 +321,16 @@ class test_Env(ClassChecker):
Test the `ipalib.config.Env._merge` method.
"""
group1 = (
- ('key1', 'value 1'),
- ('key2', 'value 2'),
- ('key3', 'value 3'),
- ('key4', 'value 4'),
+ ('key1', u'value 1'),
+ ('key2', u'value 2'),
+ ('key3', u'value 3'),
+ ('key4', u'value 4'),
)
group2 = (
- ('key0', 'Value 0'),
- ('key2', 'Value 2'),
- ('key4', 'Value 4'),
- ('key5', 'Value 5'),
+ ('key0', u'Value 0'),
+ ('key2', u'Value 2'),
+ ('key4', u'Value 4'),
+ ('key5', u'Value 5'),
)
o = self.cls()
assert o._merge(**dict(group1)) == (4, 4)
@@ -599,7 +599,7 @@ class test_Env(ClassChecker):
# Check that **lastchance works
(o, home) = self.finalize_core(None)
key = 'just_one_more_key'
- value = 'with one more value'
+ value = u'with one more value'
lastchance = {key: value}
assert key not in o
assert o._isdone('_finalize') is False
diff --git a/tests/test_xmlrpc/test_group_plugin.py b/tests/test_xmlrpc/test_group_plugin.py
index 1173ca31..620f3eac 100644
--- a/tests/test_xmlrpc/test_group_plugin.py
+++ b/tests/test_xmlrpc/test_group_plugin.py
@@ -176,7 +176,7 @@ class test_group(Declarative):
truncated=False,
result=[
dict(
- #dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn),
+ dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn),
cn=[group1],
description=[u'New desc 1'],
gidnumber=[fuzzy_digits],
@@ -293,7 +293,7 @@ class test_group(Declarative):
truncated=False,
result=[
dict(
- #dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group2, api.env.basedn),
+ dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group2, api.env.basedn),
cn=[group2],
description=[u'New desc 2'],
),
@@ -312,32 +312,32 @@ class test_group(Declarative):
truncated=False,
result=[
{
- #'dn': u'cn=admins,cn=groups,cn=accounts,%s' % api.env.basedn,
+ 'dn': u'cn=admins,cn=groups,cn=accounts,%s' % api.env.basedn,
'member_user': [u'admin'],
'gidnumber': [fuzzy_digits],
'cn': [u'admins'],
'description': [u'Account administrators group'],
},
{
- #'dn': u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn,
+ 'dn': u'cn=ipausers,cn=groups,cn=accounts,%s' % api.env.basedn,
'gidnumber': [fuzzy_digits],
'cn': [u'ipausers'],
'description': [u'Default group for all users'],
},
{
- #'dn': u'cn=editors,cn=groups,cn=accounts,%s' % api.env.basedn,
+ 'dn': u'cn=editors,cn=groups,cn=accounts,%s' % api.env.basedn,
'gidnumber': [fuzzy_digits],
'cn': [u'editors'],
'description': [u'Limited admins who can edit other users'],
},
dict(
- #dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn),
+ dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group1, api.env.basedn),
cn=[group1],
description=[u'New desc 1'],
gidnumber=[fuzzy_digits],
),
dict(
- #dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group2, api.env.basedn),
+ dn=u'cn=%s,cn=groups,cn=accounts,%s' % (group2, api.env.basedn),
cn=[group2],
description=[u'New desc 2'],
),
diff --git a/tests/test_xmlrpc/test_host_plugin.py b/tests/test_xmlrpc/test_host_plugin.py
index 753e3d2c..de30b77b 100644
--- a/tests/test_xmlrpc/test_host_plugin.py
+++ b/tests/test_xmlrpc/test_host_plugin.py
@@ -148,7 +148,7 @@ class test_host(Declarative):
summary=u'1 host matched',
result=[
dict(
- #dn=dn1,
+ dn=dn1,
fqdn=[fqdn1],
description=[u'Test host 1'],
l=[u'Undisclosed location 1'],
@@ -168,6 +168,7 @@ class test_host(Declarative):
summary=u'1 host matched',
result=[
dict(
+ dn=dn1,
cn=[fqdn1],
fqdn=[fqdn1],
description=[u'Test host 1'],
diff --git a/tests/test_xmlrpc/test_hostgroup_plugin.py b/tests/test_xmlrpc/test_hostgroup_plugin.py
index 6c0e11f0..407d9ba1 100644
--- a/tests/test_xmlrpc/test_hostgroup_plugin.py
+++ b/tests/test_xmlrpc/test_hostgroup_plugin.py
@@ -165,7 +165,7 @@ class test_hostgroup(Declarative):
summary=u'1 hostgroup matched',
result=[
{
- #'dn': dn1,
+ 'dn': dn1,
'member_host': [u'testhost1.%s' % api.env.domain],
'cn': [hostgroup1],
'description': [u'Test hostgroup 1'],
diff --git a/tests/test_xmlrpc/test_rolegroup_plugin.py b/tests/test_xmlrpc/test_rolegroup_plugin.py
index 9d0d679c..131ef068 100644
--- a/tests/test_xmlrpc/test_rolegroup_plugin.py
+++ b/tests/test_xmlrpc/test_rolegroup_plugin.py
@@ -184,7 +184,7 @@ class test_rolegroup(Declarative):
summary=u'1 rolegroup matched',
result=[
{
- #'dn': rolegroup1_dn,
+ 'dn': rolegroup1_dn,
'cn': [rolegroup1],
'description': [u'rolegroup desc 1'],
'member_group': [group1],
@@ -203,7 +203,7 @@ class test_rolegroup(Declarative):
summary=u'1 rolegroup matched',
result=[
{
- #'dn': rolegroup1_dn,
+ 'dn': rolegroup1_dn,
'cn': [rolegroup1],
'description': [u'rolegroup desc 1'],
'member_group': [group1],
@@ -240,7 +240,7 @@ class test_rolegroup(Declarative):
summary=u'1 rolegroup matched',
result=[
{
- #'dn': rolegroup1_dn,
+ 'dn': rolegroup1_dn,
'cn': [rolegroup1],
'description': [u'rolegroup desc 1'],
'member_group': [group1],
@@ -259,13 +259,13 @@ class test_rolegroup(Declarative):
summary=u'2 rolegroups matched',
result=[
{
- #'dn': rolegroup1_dn,
+ 'dn': rolegroup1_dn,
'cn': [rolegroup1],
'description': [u'rolegroup desc 1'],
'member_group': [group1],
},
{
- #'dn': rolegroup2_dn,
+ 'dn': rolegroup2_dn,
'cn': [rolegroup2],
'description': [u'rolegroup desc 2'],
},
@@ -396,7 +396,7 @@ class test_rolegroup(Declarative):
summary=u'1 rolegroup matched',
result=[
{
- #'dn': rolegroup2_dn,
+ 'dn': rolegroup2_dn,
'cn': [rolegroup2],
'description': [u'rolegroup desc 2'],
},
diff --git a/tests/test_xmlrpc/test_taskgroup_plugin.py b/tests/test_xmlrpc/test_taskgroup_plugin.py
index 2b687e68..fa728278 100644
--- a/tests/test_xmlrpc/test_taskgroup_plugin.py
+++ b/tests/test_xmlrpc/test_taskgroup_plugin.py
@@ -206,7 +206,7 @@ class test_taskgroup(Declarative):
summary=u'1 taskgroup matched',
result=[
{
- #'dn': taskgroup1_dn,
+ 'dn': taskgroup1_dn,
'cn': [taskgroup1],
'description': [u'Test desc 1'],
'member_rolegroup': [rolegroup1],
@@ -226,7 +226,7 @@ class test_taskgroup(Declarative):
summary=u'1 taskgroup matched',
result=[
{
- #'dn': taskgroup1_dn,
+ 'dn': taskgroup1_dn,
'cn': [taskgroup1],
'description': [u'Test desc 1'],
'member_rolegroup': [rolegroup1],
@@ -264,7 +264,7 @@ class test_taskgroup(Declarative):
summary=u'1 taskgroup matched',
result=[
{
- #'dn': taskgroup1_dn,
+ 'dn': taskgroup1_dn,
'cn': [taskgroup1],
'description': [u'Test desc 1'],
'member_rolegroup': [rolegroup1],
@@ -284,14 +284,14 @@ class test_taskgroup(Declarative):
summary=u'2 taskgroups matched',
result=[
{
- #'dn': taskgroup1_dn,
+ 'dn': taskgroup1_dn,
'cn': [taskgroup1],
'description': [u'Test desc 1'],
'member_rolegroup': [rolegroup1],
'member_group': [group1],
},
{
- #'dn': taskgroup2_dn,
+ 'dn': taskgroup2_dn,
'cn': [taskgroup2],
'description': [u'Test desc 2'],
},
@@ -401,7 +401,7 @@ class test_taskgroup(Declarative):
summary=u'1 taskgroup matched',
result=[
{
- #'dn': taskgroup2_dn,
+ 'dn': taskgroup2_dn,
'cn': [taskgroup2],
'description': [u'Test desc 2'],
},
diff --git a/tests/test_xmlrpc/test_user_plugin.py b/tests/test_xmlrpc/test_user_plugin.py
index b2cf6fcc..467eacf4 100644
--- a/tests/test_xmlrpc/test_user_plugin.py
+++ b/tests/test_xmlrpc/test_user_plugin.py
@@ -123,7 +123,7 @@ class test_user(Declarative):
expected=dict(
result=[
{
- #'dn': u'uid=user1,cn=users,cn=accounts,' + api.env.basedn,
+ 'dn': u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
'cn': [u'Test User1'],
'gecos': [user1],
'givenname': [u'Test'],
@@ -153,7 +153,7 @@ class test_user(Declarative):
expected=dict(
result=[
dict(
- #dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
+ dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
givenname=[u'Test'],
homedirectory=[u'/home/tuser1'],
loginshell=[u'/bin/sh'],
@@ -177,7 +177,7 @@ class test_user(Declarative):
expected=dict(
result=[
dict(
- #dn=u'uid=admin,cn=users,cn=accounts,' + api.env.basedn,
+ dn=u'uid=admin,cn=users,cn=accounts,' + api.env.basedn,
homedirectory=[u'/home/admin'],
loginshell=[u'/bin/bash'],
sn=[u'Administrator'],
@@ -185,7 +185,7 @@ class test_user(Declarative):
memberof_group=[u'admins'],
),
dict(
- #dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
+ dn=u'uid=tuser1,cn=users,cn=accounts,' + api.env.basedn,
givenname=[u'Test'],
homedirectory=[u'/home/tuser1'],
loginshell=[u'/bin/sh'],