Example #1
0
def test_scope():
    """ Test scope and scope_num property. """
    url = LDAPURL("ldap:///??one")
    assert url.scope_num == 1
    url.scope = "base"
    assert url.scope_num == 0

    with pytest.raises(TypeError):
        url.scope = 2.1
    with pytest.raises(ValueError):
        url.scope = "all"
Example #2
0
def test_scope():
    """ Test scope and scope_num property. """
    url = LDAPURL("ldap:///??one")
    assert url.scope_num == 1
    url.scope = "base"
    assert url.scope_num == 0

    with pytest.raises(TypeError):
        url.scope = 2.1
    with pytest.raises(ValueError):
        url.scope = "all"
Example #3
0
    def test_scope(self):
        """ Test scope and scope_num property. """
        url = LDAPURL("ldap:///??one")
        self.assertEqual(url.scope_num, 1)
        url.scope = "base"
        self.assertEqual(url.scope_num, 0)

        def invalid_scope_type():
            self.url.scope = 2.1

        self.assertRaises(TypeError, invalid_scope_type)

        def invalid_scope_value():
            url.scope = 'all'

        self.assertRaises(ValueError, invalid_scope_value)