Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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""")
Ejemplo n.º 3
0
 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]))
Ejemplo n.º 4
0
 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'))
Ejemplo n.º 5
0
 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')
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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')