summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-11-18 17:46:33 +0200
committerKamen Mazdrashki <kamenim@samba.org>2010-11-18 22:28:08 +0100
commit05c0bface19e8dfb395da82de6b889744768f8c6 (patch)
tree309cbaef12d6be091e0ebf6adf162f7b11c3d434
parenta403d7777e94ffdcdb57045e8a4755aced0e8484 (diff)
downloadsamba-05c0bface19e8dfb395da82de6b889744768f8c6.tar.gz
samba-05c0bface19e8dfb395da82de6b889744768f8c6.tar.bz2
samba-05c0bface19e8dfb395da82de6b889744768f8c6.zip
s4-ldb.python: add test for ldb.Message.from_dict() method
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 3e43d4ac01..b5585dcd3d 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -532,6 +532,23 @@ class LdbMsgTests(unittest.TestCase):
self.assertNotEquals(msg1, msg2)
msg2['foo'] = 'blie'
+ def test_from_dict(self):
+ rec = {"dn": "dc=fromdict",
+ "a1": ["a1-val1", "a1-val1"]}
+ l = ldb.Ldb()
+ # check different types of input Flags
+ for flags in [ldb.FLAG_MOD_ADD, ldb.FLAG_MOD_REPLACE, ldb.FLAG_MOD_DELETE]:
+ m = ldb.Message.from_dict(l, rec, flags)
+ self.assertEquals(rec["a1"], list(m["a1"]))
+ self.assertEquals(flags, m["a1"].flags())
+ # check input params
+ self.assertRaises(TypeError, ldb.Message.from_dict, dict(), rec, ldb.FLAG_MOD_REPLACE)
+ self.assertRaises(TypeError, ldb.Message.from_dict, l, list(), ldb.FLAG_MOD_REPLACE)
+ self.assertRaises(ValueError, ldb.Message.from_dict, l, rec, 0)
+ # Message.from_dict expects dictionary with 'dn'
+ err_rec = {"a1": ["a1-val1", "a1-val1"]}
+ self.assertRaises(TypeError, ldb.Message.from_dict, l, err_rec, ldb.FLAG_MOD_REPLACE)
+
class MessageElementTests(unittest.TestCase):