summaryrefslogtreecommitdiffstats
path: root/tests/test_xmlrpc/test_automount_plugin.py
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2009-08-27 15:55:19 +0200
committerRob Crittenden <rcritten@redhat.com>2009-10-05 15:59:09 -0400
commite01b1b8f99e67b08d1827b13f411f6d3cccfcf41 (patch)
tree674f392b669e5d5e46bc30dde550926494cfce4b /tests/test_xmlrpc/test_automount_plugin.py
parent1e48662b9ba623ebd8ad62035c9c84dc4f1fed70 (diff)
downloadfreeipa-e01b1b8f99e67b08d1827b13f411f6d3cccfcf41.tar.gz
freeipa-e01b1b8f99e67b08d1827b13f411f6d3cccfcf41.tar.xz
freeipa-e01b1b8f99e67b08d1827b13f411f6d3cccfcf41.zip
Fix unit tests for plugins using baseldap classes.
Diffstat (limited to 'tests/test_xmlrpc/test_automount_plugin.py')
-rw-r--r--tests/test_xmlrpc/test_automount_plugin.py116
1 files changed, 87 insertions, 29 deletions
diff --git a/tests/test_xmlrpc/test_automount_plugin.py b/tests/test_xmlrpc/test_automount_plugin.py
index d9c0c2edf..875430b4f 100644
--- a/tests/test_xmlrpc/test_automount_plugin.py
+++ b/tests/test_xmlrpc/test_automount_plugin.py
@@ -31,14 +31,24 @@ class test_automount(XMLRPC_test):
"""
Test the `automount` plugin.
"""
+ locname = u'testlocation'
mapname = u'testmap'
keyname = u'testkey'
keyname2 = u'testkey2'
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}
+ loc_kw = {'cn': locname}
+ map_kw = {'cn': locname, 'automountmapname': mapname, 'description': description, 'raw': True}
+ key_kw = {'cn': locname, 'automountmapname': mapname, 'automountkey': keyname, 'automountinformation': info, 'raw': True}
+ key_kw2 = {'cn': locname, 'automountmapname': mapname, 'automountkey': keyname2, 'automountinformation': info, 'raw': True}
+
+ def test_0_automountlocation_add(self):
+ """
+ Test adding a location `xmlrpc.automountlocation_add` method.
+ """
+ (dn, res) = api.Command['automountlocation_add'](**self.loc_kw)
+ assert res
+ assert_attr_equal(res, 'cn', self.locname)
def test_1_automountmap_add(self):
"""
@@ -79,7 +89,7 @@ class test_automount(XMLRPC_test):
"""
Test the `xmlrpc.automountmap_show` method.
"""
- (dn, res) = api.Command['automountmap_show'](self.mapname)
+ (dn, res) = api.Command['automountmap_show'](self.locname, self.mapname, raw=True)
assert res
assert_attr_equal(res, 'automountmapname', self.mapname)
@@ -87,7 +97,7 @@ class test_automount(XMLRPC_test):
"""
Test the `xmlrpc.automountmap_find` method.
"""
- (res, truncated) = api.Command['automountmap_find'](self.mapname)
+ (res, truncated) = api.Command['automountmap_find'](self.locname, self.mapname, raw=True)
assert res
assert_attr_equal(res[0][1], 'automountmapname', self.mapname)
@@ -95,7 +105,7 @@ class test_automount(XMLRPC_test):
"""
Test the `xmlrpc.automountkey_show` method.
"""
- showkey_kw={'automountmapname': self.mapname, 'automountkey': self.keyname}
+ showkey_kw={'cn': self.locname, 'automountmapname': self.mapname, 'automountkey': self.keyname, 'raw': True}
(dn, res) = api.Command['automountkey_show'](**showkey_kw)
assert res
assert_attr_equal(res, 'automountkey', self.keyname)
@@ -105,7 +115,7 @@ class test_automount(XMLRPC_test):
"""
Test the `xmlrpc.automountkey_find` method.
"""
- (res, truncated) = api.Command['automountkey_find'](self.mapname)
+ (res, truncated) = api.Command['automountkey_find'](self.locname, self.mapname, raw=True)
assert res
assert len(res) == 2
assert_attr_equal(res[1][1], 'automountkey', self.keyname)
@@ -135,7 +145,7 @@ class test_automount(XMLRPC_test):
"""
Test the `xmlrpc.automountkey_del` method.
"""
- delkey_kw={'automountmapname': self.mapname, 'automountkey': self.keyname}
+ delkey_kw={'cn': self.locname, 'automountmapname': self.mapname, 'automountkey': self.keyname, 'raw': True}
res = api.Command['automountkey_del'](**delkey_kw)
assert res == True
@@ -147,16 +157,16 @@ class test_automount(XMLRPC_test):
else:
assert False
- def test_c_automountmap_del(self):
+ def test_c_automountlocation_del(self):
"""
- Test the `xmlrpc.automountmap_del` method.
+ Test the `xmlrpc.automountlocation_del` method.
"""
- res = api.Command['automountmap_del'](self.mapname)
+ res = api.Command['automountlocation_del'](self.locname)
assert res == True
# Verify that it is gone
try:
- api.Command['automountmap_show'](self.mapname)
+ api.Command['automountlocation_show'](self.locname)
except errors.NotFound:
pass
else:
@@ -164,10 +174,10 @@ class test_automount(XMLRPC_test):
def test_d_automountmap_del(self):
"""
- Test that the `xmlrpc.automountmap_del` method removes all keys
+ Test that the `xmlrpc.automountlocation_del` method removes all maps and keys
"""
# Verify that the second key we added is gone
- key_kw = {'automountmapname': self.mapname, 'automountkey': self.keyname2}
+ key_kw = {'cn': self.locname, 'automountmapname': self.mapname, 'automountkey': self.keyname2, 'raw': True}
try:
api.Command['automountkey_show'](**key_kw)
except errors.NotFound:
@@ -180,26 +190,34 @@ class test_automount_indirect(XMLRPC_test):
"""
Test the `automount` plugin indirect map functionality.
"""
+ locname = u'testlocation'
mapname = u'auto.home'
keyname = u'/home'
parentmap = u'auto.master'
description = u'Home directories'
- map_kw = {'key': keyname, 'parentmap': parentmap, 'description': description}
+ map_kw = {'key': keyname, 'parentmap': parentmap, 'description': description, 'raw': True}
+
+ def test_0_automountlocation_add(self):
+ """
+ Test adding a location.
+ """
+ (dn, res) = api.Command['automountlocation_add'](self.locname, raw=True)
+ assert res
+ assert_attr_equal(res, 'cn', self.locname)
def test_1_automountmap_add_indirect(self):
"""
Test adding an indirect map.
"""
- (dn, res) = api.Command['automountmap_add_indirect'](self.mapname, **self.map_kw)
+ (dn, res) = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.map_kw)
assert res
- assert_attr_equal(res, 'automountinformation', self.mapname)
+ assert_attr_equal(res, 'automountmapname', self.mapname)
def test_2_automountmap_show(self):
"""
Test the `xmlrpc.automountmap_show` method.
"""
- showkey_kw = {'automountmapname': self.parentmap, 'automountkey': self.keyname}
- (dn, res) = api.Command['automountkey_show'](**showkey_kw)
+ (dn, res) = api.Command['automountkey_show'](self.locname, self.parentmap, self.keyname, raw=True)
assert res
assert_attr_equal(res, 'automountkey', self.keyname)
@@ -207,7 +225,7 @@ class test_automount_indirect(XMLRPC_test):
"""
Remove the indirect key /home.
"""
- delkey_kw = {'automountmapname': self.parentmap, 'automountkey': self.keyname}
+ delkey_kw = {'cn': self.locname, 'automountmapname': self.parentmap, 'automountkey': self.keyname}
res = api.Command['automountkey_del'](**delkey_kw)
assert res == True
@@ -223,12 +241,27 @@ class test_automount_indirect(XMLRPC_test):
"""
Remove the indirect map for auto.home.
"""
- res = api.Command['automountmap_del'](self.mapname)
+ res = api.Command['automountmap_del'](self.locname, self.mapname)
assert res == True
# Verify that it is gone
try:
- api.Command['automountmap_show'](self.mapname)
+ api.Command['automountmap_show'](self.locname, self.mapname)
+ except errors.NotFound:
+ pass
+ else:
+ assert False
+
+ def test_5_automountlocation_del(self):
+ """
+ Remove the location.
+ """
+ res = api.Command['automountlocation_del'](self.locname)
+ assert res == True
+
+ # Verity that it is gone
+ try:
+ api.Command['automountlocation_show'](self.locname)
except errors.NotFound:
pass
else:
@@ -239,25 +272,35 @@ class test_automount_indirect_no_parent(XMLRPC_test):
"""
Test the `automount` plugin Indirect map function.
"""
+ locname = u'testlocation'
mapname = u'auto.home'
keyname = u'/home'
parentmap = u'auto.master'
description = u'Home directories'
- map_kw = {'key': keyname, 'description': description}
+ map_kw = {'key': keyname, 'description': description, 'raw': True}
+
+ def test_0_automountlocation_add(self):
+ """
+ Test adding a location.
+ """
+ (dn, res) = api.Command['automountlocation_add'](self.locname, raw=True)
+ assert res
+ assert_attr_equal(res, 'cn', self.locname)
+
def test_1_automountmap_add_indirect(self):
"""
Test adding an indirect map with default parent.
"""
- (dn, res) = api.Command['automountmap_add_indirect'](self.mapname, **self.map_kw)
+ (dn, res) = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.map_kw)
assert res
- assert_attr_equal(res, 'automountinformation', self.mapname)
+ assert_attr_equal(res, 'automountmapname', self.mapname)
def test_2_automountkey_show(self):
"""
Test the `xmlrpc.automountkey_show` method with default parent.
"""
- showkey_kw = {'automountmapname': self.parentmap, 'automountkey': self.keyname}
+ showkey_kw = {'cn': self.locname, 'automountmapname': self.parentmap, 'automountkey': self.keyname, 'raw': True}
(dn, res) = api.Command['automountkey_show'](**showkey_kw)
assert res
assert_attr_equal(res, 'automountkey', self.keyname)
@@ -266,7 +309,7 @@ class test_automount_indirect_no_parent(XMLRPC_test):
"""
Remove the indirect key /home.
"""
- delkey_kw={'automountmapname': self.parentmap, 'automountkey': self.keyname}
+ delkey_kw={'cn': self.locname, 'automountmapname': self.parentmap, 'automountkey': self.keyname}
res = api.Command['automountkey_del'](**delkey_kw)
assert res == True
@@ -282,12 +325,27 @@ class test_automount_indirect_no_parent(XMLRPC_test):
"""
Remove the indirect map for auto.home.
"""
- res = api.Command['automountmap_del'](self.mapname)
+ res = api.Command['automountmap_del'](self.locname, self.mapname)
assert res == True
# Verify that it is gone
try:
- api.Command['automountmap_show'](self.mapname)
+ api.Command['automountmap_show'](self.locname, self.mapname)
+ except errors.NotFound:
+ pass
+ else:
+ assert False
+
+ def test_5_automountlocation_del(self):
+ """
+ Remove the location.
+ """
+ res = api.Command['automountlocation_del'](self.locname)
+ assert res == True
+
+ # Verity that it is gone
+ try:
+ api.Command['automountlocation_show'](self.locname)
except errors.NotFound:
pass
else: