diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-18 09:22:07 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-11-18 10:31:42 +0100 |
commit | 732ef9353dff56384e8bb01aa20d2a371cd995c2 (patch) | |
tree | a14fdbd5b50da23693af727b7ec885d0d65dbe92 /source4/lib/ldb | |
parent | ca7979e1a31ae33a99105fe821493fbded8c845f (diff) | |
download | samba-732ef9353dff56384e8bb01aa20d2a371cd995c2.tar.gz samba-732ef9353dff56384e8bb01aa20d2a371cd995c2.tar.bz2 samba-732ef9353dff56384e8bb01aa20d2a371cd995c2.zip |
s4:api.py - DN tests - test a bit more special DNs and merge the comparison tests
Diffstat (limited to 'source4/lib/ldb')
-rwxr-xr-x | source4/lib/ldb/tests/python/api.py | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py index b8adbaaf54..efb9791857 100755 --- a/source4/lib/ldb/tests/python/api.py +++ b/source4/lib/ldb/tests/python/api.py @@ -342,49 +342,74 @@ class DnTests(unittest.TestCase): x = ldb.Dn(self.ldb, "dc=foo11,bar=bloe") y = ldb.Dn(self.ldb, "dc=foo11,bar=bloe") self.assertEquals(x, y) + y = ldb.Dn(self.ldb, "dc=foo11,bar=blie") + self.assertNotEquals(x, y) + x = ldb.Dn(self.ldb, "") + y = ldb.Dn(self.ldb, "") + self.assertEquals(x, y) + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + y = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals(x, y) def test_str(self): x = ldb.Dn(self.ldb, "dc=foo12,bar=bloe") self.assertEquals(x.__str__(), "dc=foo12,bar=bloe") + x = ldb.Dn(self.ldb, "") + self.assertEquals(x.__str__(), "") + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals(x.__str__(), "cn=foo\, bar\, bar,dc=test,dc=bloe") def test_repr(self): x = ldb.Dn(self.ldb, "dc=foo13,bla=blie") self.assertEquals(x.__repr__(), "Dn('dc=foo13,bla=blie')") + x = ldb.Dn(self.ldb, "") + self.assertEquals(x.__repr__(), "Dn('')") + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals(x.__repr__(), "Dn('cn=foo\\\\, bar\\\\, bar,dc=test,dc=bloe')") def test_get_casefold(self): x = ldb.Dn(self.ldb, "dc=foo14,bar=bloe") self.assertEquals(x.get_casefold(), "DC=FOO14,BAR=bloe") + x = ldb.Dn(self.ldb, "") + self.assertEquals(x.get_casefold(), "") + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals(x.get_casefold(), "CN=FOO\, BAR\, BAR,DC=TEST,DC=BLOE") def test_validate(self): x = ldb.Dn(self.ldb, "dc=foo15,bar=bloe") self.assertTrue(x.validate()) + x = ldb.Dn(self.ldb, "") + self.assertTrue(x.validate()) # the empty DN is valid (rootDSE) + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertTrue(x.validate()) def test_parent(self): x = ldb.Dn(self.ldb, "dc=foo16,bar=bloe") self.assertEquals("bar=bloe", x.parent().__str__()) + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals("dc=test,dc=bloe", x.parent().__str__()) def test_parent_nonexistant(self): x = ldb.Dn(self.ldb, "@BLA") self.assertEquals(None, x.parent()) - - def test_compare(self): - x = ldb.Dn(self.ldb, "dc=foo17,bar=bloe") - y = ldb.Dn(self.ldb, "dc=foo17,bar=bloe") - self.assertEquals(x, y) - z = ldb.Dn(self.ldb, "dc=foo17,bar=blie") - self.assertNotEquals(z, y) + x = ldb.Dn(self.ldb, "") + self.assertEquals(None, x.parent()) def test_is_valid(self): x = ldb.Dn(self.ldb, "dc=foo18,dc=bloe") self.assertTrue(x.is_valid()) x = ldb.Dn(self.ldb, "") - # is_valid()'s return values appears to be a side effect of - # some other ldb functions. yuck. - # self.assertFalse(x.is_valid()) + self.assertTrue(x.is_valid()) # the empty DN is valid (rootDSE) + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertTrue(x.is_valid()) def test_is_special(self): x = ldb.Dn(self.ldb, "dc=foo19,bar=bloe") self.assertFalse(x.is_special()) + x = ldb.Dn(self.ldb, "") + self.assertFalse(x.is_special()) + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertFalse(x.is_special()) x = ldb.Dn(self.ldb, "@FOOBAR") self.assertTrue(x.is_special()) @@ -399,6 +424,10 @@ class DnTests(unittest.TestCase): self.assertEquals(2, len(x)) x = ldb.Dn(self.ldb, "dc=foo21") self.assertEquals(1, len(x)) + x = ldb.Dn(self.ldb, "") + self.assertEquals(0, len(x)) # the empty DN has length 0 + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals(3, len(x)) def test_add_child(self): x = ldb.Dn(self.ldb, "dc=foo22,bar=bloe") @@ -434,11 +463,18 @@ class DnTests(unittest.TestCase): def test_canonical_string(self): x = ldb.Dn(self.ldb, "dc=foo25,bar=bloe") self.assertEquals("/bloe/foo25", x.canonical_str()) + x = ldb.Dn(self.ldb, "") + self.assertEquals("/", x.canonical_str()) + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals("test.bloe/foo\, bar\, bar", x.canonical_str()) def test_canonical_ex_string(self): x = ldb.Dn(self.ldb, "dc=foo26,bar=bloe") self.assertEquals("/bloe\nfoo26", x.canonical_ex_str()) - + x = ldb.Dn(self.ldb, "") + self.assertEquals("\n", x.canonical_ex_str()) + x = ldb.Dn(self.ldb, "cn=foo\, bar\, bar,dc=test,dc=bloe") + self.assertEquals("test.bloe\nfoo\, bar\, bar", x.canonical_ex_str()) class LdbMsgTests(unittest.TestCase): |