def test_case_insensitive(self): item = simpleldap.LDAPItem(self.mock_results[0]) self.assertEqual(item['cn'], ['Joseph Smith', 'Joseph Smith Jr.']) self.assertEqual(item['cn'], item['CN']) self.assertEqual(item.first('cn'), item.first('CN')) self.assertTrue('cn' in item) self.assertTrue('CN' in item)
def test_str(self): item = simpleldap.LDAPItem(self.mock_results[0]) self.assertEqual(str(item), """\ cn: Joseph Smith Joseph Smith Jr. displayName: Joe L. Smith Joe Smith givenName: Joseph sn: Smith""")
def test_equals(self): self.assertEqual(simpleldap.LDAPItem(self.mock_results[0]), simpleldap.LDAPItem(self.mock_results[0])) self.assertNotEqual(simpleldap.LDAPItem(self.mock_results[0]), simpleldap.LDAPItem(self.mock_results[1]))
def test_value_contains(self): item = simpleldap.LDAPItem(self.mock_results[0]) self.assertTrue(item.value_contains('Joseph', 'cn')) self.assertFalse(item.value_contains('Bob', 'cn'))
def test_first_lookup(self): item = simpleldap.LDAPItem(self.mock_results[0]) self.assertEqual(item.first('cn'), 'Joseph Smith') self.assertEqual(item.first('sn'), 'Smith') self.assertRaises(KeyError, item.first, 'foo')
def test_item_lookup(self): item = simpleldap.LDAPItem(self.mock_results[0]) self.assertEqual(item['cn'], ['Joseph Smith', 'Joseph Smith Jr.']) self.assertRaises(KeyError, itemgetter('foo'), item)
def test_dn(self): item = simpleldap.LDAPItem(self.mock_results[0]) self.assertEqual(item.dn, 'uid=joe,ou=people,dc=directory,dc=example,dc=com')