RHEL: Instead of not running the tests, skip tests requiring openldap-servers

The openldap-servers package is not available in RHEL.
Previously, tests were not run on RHEL because of that.
Now the tests run, but the ones that require openldap-servers are skipped.

Resolves: RHEL-61809
This commit is contained in:
Simon Pichugin 2024-10-10 22:42:42 -07:00
parent bddaab5cf1
commit afe0e4d8f6
2 changed files with 148 additions and 1 deletions

View File

@ -0,0 +1,136 @@
From 127a761c915e4d445f5f8a02a9a4e0b42b2bf7aa Mon Sep 17 00:00:00 2001
From: Simon Pichugin <spichugi@redhat.com>
Date: Tue, 8 Oct 2024 19:01:36 -0700
Subject: [PATCH] Disable openldap-servers tests
---
Tests/t_bind.py | 1 +
Tests/t_cext.py | 1 +
Tests/t_edit.py | 1 +
Tests/t_ldap_options.py | 1 +
Tests/t_ldap_sasl.py | 1 +
Tests/t_ldap_schema_subentry.py | 1 +
Tests/t_ldap_syncrepl.py | 2 ++
Tests/t_ldapobject.py | 1 +
Tests/t_slapdobject.py | 1 +
9 files changed, 10 insertions(+)
diff --git a/Tests/t_bind.py b/Tests/t_bind.py
index ba90c4c..653b871 100644
--- a/Tests/t_bind.py
+++ b/Tests/t_bind.py
@@ -9,6 +9,7 @@ from ldap.ldapobject import LDAPObject
from slapdtest import SlapdTestCase
+@unittest.skip("openldap-server package is absent")
class TestBinds(SlapdTestCase):
unicode_val = "abc\U0001f498def"
unicode_val_bytes = unicode_val.encode('utf-8')
diff --git a/Tests/t_cext.py b/Tests/t_cext.py
index 33fbf29..8035354 100644
--- a/Tests/t_cext.py
+++ b/Tests/t_cext.py
@@ -17,6 +17,7 @@ import _ldap
from slapdtest import SlapdTestCase, requires_tls, requires_init_fd
+@unittest.skip("openldap-server package is absent")
class TestLdapCExtension(SlapdTestCase):
"""
These tests apply only to the _ldap module and therefore bypass the
diff --git a/Tests/t_edit.py b/Tests/t_edit.py
index 5d8b3f0..757de9d 100644
--- a/Tests/t_edit.py
+++ b/Tests/t_edit.py
@@ -9,6 +9,7 @@ from ldap.ldapobject import LDAPObject
from slapdtest import SlapdTestCase
+@unittest.skip("openldap-server package is absent")
class EditionTests(SlapdTestCase):
@classmethod
diff --git a/Tests/t_ldap_options.py b/Tests/t_ldap_options.py
index e9bef59..2fea7a3 100644
--- a/Tests/t_ldap_options.py
+++ b/Tests/t_ldap_options.py
@@ -135,6 +135,7 @@ class TestGlobalOptions(BaseTestOptions, unittest.TestCase):
return ldap.set_option(option, value)
+@unittest.skip("openldap-server package is absent")
class TestLDAPObjectOptions(BaseTestOptions, SlapdTestCase):
"""Test setting/getting connection-specific options
"""
diff --git a/Tests/t_ldap_sasl.py b/Tests/t_ldap_sasl.py
index 40ab27e..ef6aec0 100644
--- a/Tests/t_ldap_sasl.py
+++ b/Tests/t_ldap_sasl.py
@@ -37,6 +37,7 @@ cn: {certuser}
"""
+@unittest.skip("openldap-server package is absent")
@requires_sasl()
class TestSasl(SlapdTestCase):
ldap_object_class = SimpleLDAPObject
diff --git a/Tests/t_ldap_schema_subentry.py b/Tests/t_ldap_schema_subentry.py
index 60a584d..691fc5b 100644
--- a/Tests/t_ldap_schema_subentry.py
+++ b/Tests/t_ldap_schema_subentry.py
@@ -236,6 +236,7 @@ class TestAttributes(unittest.TestCase):
self.assertEqual(cls.x_origin, ('RFC 4519',))
+@unittest.skip("openldap-server package is absent")
class TestSubschemaUrlfetchSlapd(SlapdTestCase):
ldap_object_class = SimpleLDAPObject
diff --git a/Tests/t_ldap_syncrepl.py b/Tests/t_ldap_syncrepl.py
index 6acc82c..7e54830 100644
--- a/Tests/t_ldap_syncrepl.py
+++ b/Tests/t_ldap_syncrepl.py
@@ -265,6 +265,7 @@ class SyncreplClient(SimpleLDAPObject, SyncreplConsumer):
pass
+@unittest.skip("openldap-server package is absent")
class BaseSyncreplTests:
"""
This is a test of all the basic Syncrepl operations. It covers starting a
@@ -430,6 +431,7 @@ class BaseSyncreplTests:
# should pick it up during the persist phase.
+@unittest.skip("openldap-server package is absent")
class TestSyncrepl(BaseSyncreplTests, SlapdTestCase):
def setUp(self):
super().setUp()
diff --git a/Tests/t_ldapobject.py b/Tests/t_ldapobject.py
index ada5f99..825c2f5 100644
--- a/Tests/t_ldapobject.py
+++ b/Tests/t_ldapobject.py
@@ -88,6 +88,7 @@ olcObjectClasses: ( 1.3.6.1.4.1.56207.1.2.2 NAME 'myClass'
X-ORIGIN 'foobar' )"""
+@unittest.skip("openldap-server package is absent")
class Test00_SimpleLDAPObject(SlapdTestCase):
"""
test LDAP search operations
diff --git a/Tests/t_slapdobject.py b/Tests/t_slapdobject.py
index e1cc971..c9b693d 100644
--- a/Tests/t_slapdobject.py
+++ b/Tests/t_slapdobject.py
@@ -3,6 +3,7 @@ import unittest
import slapdtest
+@unittest.skip("openldap-server package is absent")
class TestSlapdObject(unittest.TestCase):
def test_context_manager(self):
with slapdtest.SlapdObject() as server:
--
2.46.0

View File

@ -1,4 +1,6 @@
### Abstract ###
%bcond servers %{undefined rhel}
# global prerelease b4
%global openldap_version 2.4.45-4
@ -12,6 +14,8 @@ Summary: An object-oriented API to access LDAP directory servers
URL: https://python-ldap.org/
Source0: %{pypi_source}
# Conditionally applied paches, numbereed > 100
Patch101: 0101-Disable-openldap-servers-tests.patch
### Build Dependencies ###
BuildRequires: gcc
@ -21,7 +25,9 @@ BuildRequires: cyrus-sasl-devel
BuildRequires: python3-devel
BuildRequires: python3-setuptools
# Test dependencies
%if %{with servers}
BuildRequires: openldap-servers >= %{openldap_version}
%endif
BuildRequires: openldap-clients >= %{openldap_version}
BuildRequires: python3-pyasn1 >= 0.3.7
BuildRequires: python3-pyasn1-modules >= 0.1.5
@ -51,7 +57,12 @@ Provides: python3-pyldap%{?_isa} = %{version}-%{release}
%prep
%autosetup -p1 -n %{name}-%{version}%{?prerelease}
%autosetup -p1 -n %{name}-%{version}%{?prerelease} -N
%autopatch -p1 -M100
%if %{without servers}
%autopatch -p1 101
%endif
# Fix interpreter
find . -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{__python3}|'