From da5c9406ff3f0196b8e27a674cfba64ffd171f75 Mon Sep 17 00:00:00 2001 From: Morten Brekkevold Date: Fri, 8 Dec 2023 15:48:24 +0100 Subject: [PATCH] Skip LDAP tests if LDAP library isn't available LDAP *is* marked as an optional dependency, so the test suite should still complete without it. --- tests/unittests/general/webfront_test.py | 6 ++++++ tests/unittests/web/ldapauth_test.py | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/tests/unittests/general/webfront_test.py b/tests/unittests/general/webfront_test.py index 5b23d931d5..23f538df01 100644 --- a/tests/unittests/general/webfront_test.py +++ b/tests/unittests/general/webfront_test.py @@ -178,6 +178,9 @@ def test_remote_user_set(self): ) +@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", @@ -277,6 +280,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) diff --git a/tests/unittests/web/ldapauth_test.py b/tests/unittests/web/ldapauth_test.py index 2655f1166d..757ad9434b 100644 --- a/tests/unittests/web/ldapauth_test.py +++ b/tests/unittests/web/ldapauth_test.py @@ -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"""