mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
pyldb: Add tests for ldb.Message containment testing
These tests verify that the 'in' operator on ldb.Message is consistent with indexing and the get() method. This means that the 'dn' element should always be present, lookups should be case-insensitive, and use of an invalid type should result in a TypeError. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14845 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
22353767ca
commit
865fe23859
@ -3203,6 +3203,29 @@ class LdbMsgTests(TestCase):
|
||||
def test_get_unknown_text(self):
|
||||
self.assertEqual(None, self.msg.text.get("lalalala"))
|
||||
|
||||
def test_contains(self):
|
||||
self.msg['foo'] = ['bar']
|
||||
self.assertIn('foo', self.msg)
|
||||
|
||||
self.msg['Foo'] = ['bar']
|
||||
self.assertIn('Foo', self.msg)
|
||||
|
||||
def test_contains_case(self):
|
||||
self.msg['foo'] = ['bar']
|
||||
self.assertIn('Foo', self.msg)
|
||||
|
||||
self.msg['Foo'] = ['bar']
|
||||
self.assertIn('foo', self.msg)
|
||||
|
||||
def test_contains_dn(self):
|
||||
self.assertIn('dn', self.msg)
|
||||
|
||||
def test_contains_dn_case(self):
|
||||
self.assertIn('DN', self.msg)
|
||||
|
||||
def test_contains_invalid(self):
|
||||
self.assertRaises(TypeError, lambda: None in self.msg)
|
||||
|
||||
def test_msg_diff(self):
|
||||
l = ldb.Ldb()
|
||||
msgs = l.parse_ldif("dn: foo=bar\nfoo: bar\nbaz: do\n\ndn: foo=bar\nfoo: bar\nbaz: dont\n")
|
||||
|
4
selftest/knownfail.d/pyldb
Normal file
4
selftest/knownfail.d/pyldb
Normal file
@ -0,0 +1,4 @@
|
||||
^ldb.python.api.LdbMsgTests.test_contains_case
|
||||
^ldb.python.api.LdbMsgTests.test_contains_dn
|
||||
^ldb.python.api.LdbMsgTests.test_contains_dn_case
|
||||
^ldb.python.api.LdbMsgTests.test_contains_invalid
|
Loading…
Reference in New Issue
Block a user