Author: jelmer Date: 2007-10-14 18:39:39 +0000 (Sun, 14 Oct 2007) New Revision: 25635
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25635 Log: Add __len__, add_child, add_base on ldb_dn. Modified: branches/4.0-python/ branches/4.0-python/source/lib/ldb/swig/ldb.i branches/4.0-python/source/lib/ldb/tests/python/api.py Changeset: Property changes on: branches/4.0-python ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/4.0-python/source/lib/ldb/swig/ldb.i =================================================================== --- branches/4.0-python/source/lib/ldb/swig/ldb.i 2007-10-14 18:30:51 UTC (rev 25634) +++ branches/4.0-python/source/lib/ldb/swig/ldb.i 2007-10-14 18:39:39 UTC (rev 25635) @@ -125,6 +125,7 @@ %rename(__str__) ldb_dn::get_linearized; %rename(__cmp__) ldb_dn::compare; +%rename(__len__) ldb_dn::get_comp_num; %rename(Dn) ldb_dn; typedef struct ldb_dn { %extend { @@ -151,6 +152,9 @@ bool is_special(); bool is_null(); bool check_special(const char *name); + int get_comp_num(); + bool add_child(ldb_dn *child); + bool add_base(ldb_dn *base); } } ldb_dn; Modified: branches/4.0-python/source/lib/ldb/tests/python/api.py =================================================================== --- branches/4.0-python/source/lib/ldb/tests/python/api.py 2007-10-14 18:30:51 UTC (rev 25634) +++ branches/4.0-python/source/lib/ldb/tests/python/api.py 2007-10-14 18:39:39 UTC (rev 25635) @@ -87,7 +87,22 @@ x = ldb.Dn(self.ldb, "@FOOBAR") self.assertTrue(x.check_special("@FOOBAR")) + def test_len(self): + x = ldb.Dn(self.ldb, "dc=foo,bar=bloe") + self.assertEquals(2, len(x)) + x = ldb.Dn(self.ldb, "dc=foo") + self.assertEquals(1, len(x)) + def test_add_child(self): + x = ldb.Dn(self.ldb, "dc=foo,bar=bloe") + self.assertTrue(x.add_child(ldb.Dn(self.ldb, "bla=bloe"))) + self.assertEquals("bla=bloe,dc=foo,bar=bloe", x.__str__()) + + def test_add_base(self): + x = ldb.Dn(self.ldb, "dc=foo,bar=bloe") + self.assertTrue(x.add_base(ldb.Dn(self.ldb, "bla=bloe"))) + self.assertEquals("dc=foo,bar=bloe,bla=bloe", x.__str__()) + class LdbMsgTests(unittest.TestCase): def setUp(self): self.msg = ldb.Message()
