Fix remaining issues with XML-RPC test cases

Tied the make-test script into the test target of the top-level Makefile
Added code to xmlrpc_test.py so that it configures the API if it isn't
already done which enables individual tests to be executed.
This commit is contained in:
Rob Crittenden 2009-02-03 15:03:17 -05:00
parent 2d7e0de5ea
commit 98d4644bff
8 changed files with 37 additions and 26 deletions

View File

@ -59,9 +59,7 @@ install: all server-install
done
test:
@for subdir in $(SUBDIRS); do \
(cd $$subdir && $(MAKE) $@) || exit 1; \
done
./make-test
release-update:
if [ ! -e RELEASE ]; then echo 0 > RELEASE; fi

View File

@ -24,18 +24,18 @@ Test the `ipalib/plugins/f_automount' module.
import sys
from xmlrpc_test import XMLRPC_test
from ipalib import api
from ipalib import errors
from ipalib import errors2
class test_Service(XMLRPC_test):
"""
Test the `f_automount` plugin.
"""
mapname='testmap'
keyname='testkey'
keyname2='secondkey'
description='description of map'
info='ro'
mapname=u'testmap'
keyname=u'testkey'
keyname2=u'secondkey'
description=u'description of map'
info=u'ro'
map_kw={'automountmapname': mapname, 'description': description}
key_kw={'automountmapname': mapname, 'automountkey': keyname, 'automountinformation': info}
key_kw2={'automountmapname': mapname, 'automountkey': keyname2, 'automountinformation': info}
@ -116,8 +116,8 @@ class test_Service(XMLRPC_test):
"""
Test the `xmlrpc.automount_modkey` method.
"""
self.key_kw['automountinformation'] = 'rw'
self.key_kw['description'] = 'new description'
self.key_kw['automountinformation'] = u'rw'
self.key_kw['description'] = u'new description'
res = api.Command['automount_modkey'](**self.key_kw)
assert res
assert res.get('automountkey','') == self.keyname
@ -128,11 +128,11 @@ class test_Service(XMLRPC_test):
"""
Test the `xmlrpc.automount_modmap` method.
"""
self.map_kw['description'] = 'new description'
self.map_kw['description'] = u'new description'
res = api.Command['automount_modmap'](**self.map_kw)
assert res
assert res.get('automountmapname','') == self.mapname
assert res.get('description','') == 'new description'
assert res.get('description','') == u'new description'
def test_remove1key(self):
"""
@ -182,10 +182,10 @@ class test_Indirect(XMLRPC_test):
"""
Test the `f_automount` plugin Indirect map function.
"""
mapname='auto.home'
keyname='/home'
parentmap='auto.master'
description='Home directories'
mapname=u'auto.home'
keyname=u'/home'
parentmap=u'auto.master'
description=u'Home directories'
map_kw={'automountkey': keyname, 'parentmap': parentmap, 'description': description}
def test_add_indirect(self):

View File

@ -78,7 +78,7 @@ class test_Group(XMLRPC_test):
Test the `xmlrpc.group_add_member` with a non-existent member
"""
kw={}
kw['groups'] = "notfound"
kw['groups'] = u"notfound"
res = api.Command['group_add_member'](self.cn, **kw)
# an error isn't thrown, the list of failed members is returned
assert res != []
@ -137,7 +137,7 @@ class test_Group(XMLRPC_test):
Test the `xmlrpc.group_remove_member` method with non-member
"""
kw={}
kw['groups'] = "notfound"
kw['groups'] = u"notfound"
# an error isn't thrown, the list of failed members is returned
res = api.Command['group_remove_member'](self.cn, **kw)
assert res != []

View File

@ -24,14 +24,14 @@ Test the `ipalib/plugins/f_host` module.
import sys
from xmlrpc_test import XMLRPC_test
from ipalib import api
from ipalib import errors
from ipalib import errors2
class test_Host(XMLRPC_test):
"""
Test the `f_host` plugin.
"""
cn = api.env.host.decode('UTF-8')
cn = u'ipatesthost.%s' % api.env.domain
description = u'Test host'
localityname = u'Undisclosed location'
kw={'cn': cn, 'description': description, 'localityname': localityname}

View File

@ -24,7 +24,7 @@ Test the `ipalib/plugins/f_hostgroup` module.
import sys
from xmlrpc_test import XMLRPC_test
from ipalib import api
from ipalib import errors
from ipalib import errors2
class test_Host(XMLRPC_test):
@ -35,7 +35,7 @@ class test_Host(XMLRPC_test):
description=u'Test host group'
kw={'cn': cn, 'description': description}
host_cn = api.env.host.decode('UTF-8')
host_cn = u'ipatesthost.%s' % api.env.domain
host_description = u'Test host'
host_localityname = u'Undisclosed location'

View File

@ -45,7 +45,7 @@ class test_Netgroup(XMLRPC_test):
ng_description=u'Netgroup'
ng_kw={'cn': ng_cn, 'description': ng_description}
host_cn = api.env.host.decode('UTF-8')
host_cn = u'ipatesthost.%s' % api.env.domain
host_description=u'Test host'
host_localityname=u'Undisclosed location'
host_kw={'cn': host_cn, 'description': host_description, 'localityname': host_localityname}

View File

@ -75,8 +75,8 @@ class test_User(XMLRPC_test):
"""
Test the `xmlrpc.user_find` method with all attributes.
"""
kw={'uid':self.uid, 'all': True}
res = api.Command['user_find'](**kw)
kw={'all': True}
res = api.Command['user_find'](self.uid, **kw)
assert res
assert len(res) == 2
assert res[1].get('givenname','') == self.givenname

View File

@ -26,7 +26,20 @@ import socket
import nose
from ipalib import api, request
from ipalib import errors2
from ipalib import errors
# Initialize the API. We do this here so that one can run the tests
# individually instead of at the top-level. If API.bootstrap()
# has already been called we continue gracefully. Other errors will be
# raised.
try:
api.bootstrap(context='cli')
api.finalize()
except StandardError, e:
if str(e) == "API.bootstrap() already called":
pass
else:
raise e
class XMLRPC_test(object):
"""