def test_init_errors(self): """ Testing errors during initialization of LDAPReference. """ client = LDAPClient(self.url) self.assertRaises(TypeError, lambda: LDAPReference(None, ["ldap://a"])) self.assertRaises(TypeError, lambda: LDAPReference(client, [0])) self.assertRaises( ValueError, lambda: LDAPReference(client, ["asd", LDAPURL("ldap://b")]))
def test_references_prop(host_url): """ Testing references property. """ client = LDAPClient(host_url) reflist = [LDAPURL("ldap://localhost"), host_url] ref = LDAPReference(client, reflist) assert ref.references == reflist with pytest.raises(ValueError): ref.references = None
def test_init_errors(host_url): """ Testing errors during initialization of LDAPReference. """ client = LDAPClient(host_url) with pytest.raises(TypeError): _ = LDAPReference(None, ["ldap://a"]) with pytest.raises(TypeError): _ = LDAPReference(client, [0]) with pytest.raises(ValueError): _ = LDAPReference(client, ["asd", LDAPURL("ldap://b")])
def test_client_prop(host_url): """ Testing client property. """ client = LDAPClient(host_url) ref = LDAPReference(client, []) assert ref.client == client with pytest.raises(TypeError): ref.client = "b" ref.client = LDAPClient() assert ref.client != client
def test_client_prop(self): """ Testing client property. """ client = LDAPClient(self.url) ref = LDAPReference(client, []) self.assertEqual(ref.client, client) def error(): ref.client = "b" self.assertRaises(TypeError, error) ref.client = LDAPClient() self.assertNotEqual(ref.client, client)
def test_references_prop(self): """ Testing references property. """ client = LDAPClient(self.url) reflist = [LDAPURL("ldap://localhost"), self.url] ref = LDAPReference(client, reflist) self.assertCountEqual(ref.references, reflist) def error(): ref.references = None self.assertRaises(ValueError, error)