From 7e7ea25030ad855b3037d6a43f63a83c433bf0c4 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 325a87842e..58e085aec3 100644 --- a/tests/unittests/general/webfront_test.py +++ b/tests/unittests/general/webfront_test.py @@ -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", @@ -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) 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"""