Skip to content

Commit

Permalink
Skip LDAP tests if LDAP library isn't available
Browse files Browse the repository at this point in the history
LDAP *is* marked as an optional dependency, so the test suite should
still complete without it.
  • Loading branch information
lunkwill42 committed Sep 24, 2024
1 parent 9d290b4 commit 7e7ea25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/unittests/general/webfront_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ def test_remote_user_set(self, fake_session):
)


@pytest.mark.skipif(
not nav.web.auth.ldap.available, reason="ldap module is not available"
)
class TestLdapUser(object):
@patch.dict(
"nav.web.auth.ldap._config._sections",
Expand Down Expand Up @@ -269,6 +272,9 @@ def fake_search(base, scope, filtr):
},
},
)
@pytest.mark.skipif(
not nav.web.auth.ldap.available, reason="ldap module is not available"
)
class TestLdapEntitlements(object):
def test_required_entitlement_should_be_verified(self, user_zaphod):
u = nav.web.auth.ldap.LDAPUser("zaphod", user_zaphod)
Expand Down
8 changes: 8 additions & 0 deletions tests/unittests/web/ldapauth_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import pytest

import nav.web.auth.ldap
from nav.config import NAVConfigParser
from nav.web.auth.ldap import LDAPUser, open_ldap
from mock import Mock, patch


pytestmark = pytest.mark.skipif(
not nav.web.auth.ldap.available, reason="ldap module is not available"
)


class LdapTestConfig(NAVConfigParser):
DEFAULT_CONFIG_FILES = []
DEFAULT_CONFIG = u"""
Expand Down

0 comments on commit 7e7ea25

Please sign in to comment.