From 27a6aa9704a0c2c6ddb43acfc39f0710ec37da31 Mon Sep 17 00:00:00 2001 From: Robert Niederreiter Date: Wed, 20 Nov 2024 08:18:10 +0100 Subject: [PATCH] Makefile settings, custom targets, prepare for pytest --- .github/workflows/test.yml | 23 ++++++++++ .gitignore | 18 +++----- .travis.yml | 46 ------------------- LICENSE.rst | 2 +- Makefile | 14 +++--- README.rst | 16 +++---- bootstrap.sh | 15 ------ buildout.cfg | 35 -------------- etc/base.cfg | 81 --------------------------------- etc/ldap.cfg | 45 ------------------ etc/versions.cfg | 7 --- i18n.sh | 46 ------------------- include.mk | 43 +++++++++++++++++ run_tests.sh | 17 ------- setup.py | 27 ++--------- src/cone/ldap/tests/__init__.py | 32 ------------- 16 files changed, 91 insertions(+), 376 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml delete mode 100755 bootstrap.sh delete mode 100644 buildout.cfg delete mode 100644 etc/base.cfg delete mode 100644 etc/ldap.cfg delete mode 100644 etc/versions.cfg delete mode 100755 i18n.sh create mode 100644 include.mk delete mode 100755 run_tests.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..29ba1b6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: Tests + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + python: + - "3.9" + - "3.10" + - "3.11" + - "3.12" + - "3.13" + + steps: + - uses: actions/checkout@v3 + + - name: Run Tests + run: make test diff --git a/.gitignore b/.gitignore index 23fb8bb..cfd2eab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,12 @@ +*.egg-info/ *.pyc /.installed.cfg -/.mr.developer.cfg +/.mxmake/ /bin/ +/constraints-mxdev.txt /coverage/ -/develop-eggs/ -/devsrc/ /dist/ -/eggs/ -/include/ -/lib/ -/local/ -/parts/ -/pyvenv.cfg -/share/ -/src/cone.ldap.egg-info/ +/openldap/ +/requirements-mxdev.txt +/sources/ +/venv/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9884c89..0000000 --- a/.travis.yml +++ /dev/null @@ -1,46 +0,0 @@ -dist: bionic -language: python -sudo: false - -python: - - "2.7" - - "3.5" - - "3.6" - - "3.7" - - "3.8" - -addons: - apt: - packages: - - libsasl2-dev - - libssl-dev - - libdb-dev - -before_script: - - export TZ=Europe/Vienna - -install: - - virtualenv . - - bin/pip install coverage - - bin/pip install coveralls - - bin/pip install pyramid==1.9.4 - - | - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then - bin/pip install repoze.zcml==0.4 - bin/pip install repoze.workflow==0.6.1 - bin/pip install Pillow==6.2.2 - bin/pip install natsort==6.2.0 - else - bin/pip install repoze.zcml==1.1 - bin/pip install repoze.workflow==1.1 - fi - - bin/pip install --upgrade pip setuptools zc.buildout - - bin/buildout -N - -script: - - bin/py -m cone.ldap.tests.__init__ - - bin/coverage run --source src/cone/ldap -m cone.ldap.tests.__init__ - - bin/coverage report - -after_success: - - bin/coveralls diff --git a/LICENSE.rst b/LICENSE.rst index 3b1bc71..444cf33 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -2,7 +2,7 @@ License ======= Copyright (c) 2019-2021, BlueDynamics Alliance, Austria -Copyright (c) 2021-2022, Cone Contributors +Copyright (c) 2021-2024, Cone Contributors All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Makefile b/Makefile index bf9e8eb..91490d6 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ PYTHON_MIN_VERSION?=3.9 # `VENV_ENABLED` and uv is selected, uv is used to create the virtual # environment. # Default: pip -PYTHON_PACKAGE_INSTALLER?=pip +PYTHON_PACKAGE_INSTALLER?=uv # Flag whether to use a global installed 'uv' or install # it in the virtual environment. @@ -103,7 +103,7 @@ VENV_CREATE?=true # `VENV_CREATE` is false it is expected to point to an existing virtual # environment. If `VENV_ENABLED` is `false` it is ignored. # Default: .venv -VENV_FOLDER?=.venv +VENV_FOLDER?=venv # mxdev to install in virtual environment. # Default: mxdev @@ -171,25 +171,25 @@ ZEST_RELEASER_FULLRELEASE_OPTIONS?= # Path of directory containing the message catalogs. # Default: locale -GETTEXT_LOCALES_PATH?=locale +GETTEXT_LOCALES_PATH?=src/cone/ldap/locale # Translation domain to use. # No default value. -GETTEXT_DOMAIN?= +GETTEXT_DOMAIN?=cone.ldap # Space separated list of language identifiers. # No default value. -GETTEXT_LANGUAGES?= +GETTEXT_LANGUAGES?=en de ## i18n.lingua # Path of directory to extract translatable texts from. # Default: src -LINGUA_SEARCH_PATH?=src +LINGUA_SEARCH_PATH?=src/cone/ldap # Python packages containing lingua extensions. # No default value. -LINGUA_PLUGINS?= +LINGUA_PLUGINS?=yafowil.lingua # Command line options passed to `pot-create` # No default value. diff --git a/README.rst b/README.rst index cafd9fc..1592e31 100644 --- a/README.rst +++ b/README.rst @@ -6,11 +6,9 @@ :target: https://pypi.python.org/pypi/cone.ldap :alt: Number of PyPI downloads -.. image:: https://travis-ci.org/bluedynamics/cone.ldap.svg?branch=master - :target: https://travis-ci.org/bluedynamics/cone.ldap - -.. image:: https://coveralls.io/repos/github/bluedynamics/cone.ldap/badge.svg?branch=master - :target: https://coveralls.io/github/bluedynamics/cone.ldap?branch=master +.. image:: https://github.com/conestack/cone.ldap/actions/workflows/test.yml/badge.svg + :target: https://github.com/conestack/cone.ldap/actions/workflows/test.yml + :alt: Test cone.ldap Plugin for `cone.app `_ providing LDAP integration. @@ -46,24 +44,24 @@ On debian based systems install: Installation ------------ -``cone.ldap`` contains a buildout configuration. Download or checkout package +``cone.ldap`` contains a Makefile. Download or checkout package and run: .. code-block:: shell - cone.ldap$ ./bootstrap.sh python3 + cone.ldap$ make install Start Test LDAP server with appropriate LDIF layer: .. code-block:: shell - cone.ldap$ ./bin/testldap start groupOfNames_10_10 + cone.ldap$ make start-ldap-gon-10-10 Start the application: .. code-block:: shell - cone.ldap$ ./bin/pserve cfg/gon_10_10/ldap_gon_10_10.ini + cone.ldap$ make run-gon-10-10 and browse ``http://localhost:8081/``. Default ``admin`` user password is ``admin``. diff --git a/bootstrap.sh b/bootstrap.sh deleted file mode 100755 index 430cef9..0000000 --- a/bootstrap.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -for dir in lib include local bin share parts; do - if [ -d "$dir" ]; then - rm -rf "$dir" - fi -done - -PY=$1 -if [ "$PY" == "" ]; then - PY=python2 -fi - -virtualenv -p $PY . -./bin/pip install -U pip wheel setuptools zc.buildout -./bin/buildout -N diff --git a/buildout.cfg b/buildout.cfg deleted file mode 100644 index 68d7bc2..0000000 --- a/buildout.cfg +++ /dev/null @@ -1,35 +0,0 @@ -[buildout] -extends = etc/base.cfg - -extensions = mr.developer -sources-dir = ${buildout:directory}/devsrc -always-checkout = force -auto-checkout = * - -[remotes] -cs = https://github.com/conestack -cs_push = git@github.com:conestack -bda = https://github.com/bluedynamics -bda_push = git@github.com:bluedynamics - -[sources] -odict = git ${remotes:cs_push}/odict.git pushurl=${remotes:cs_push}/odict.git -plumber = git ${remotes:cs_push}/plumber.git pushurl=${remotes:cs_push}/plumber.git -node = git ${remotes:cs_push}/node.git pushurl=${remotes:cs_push}/node.git -node.ext.ugm = git ${remotes:cs_push}/node.ext.ugm.git pushurl=${remotes:cs_push}/node.ext.ugm.git -node.ext.ldap = git ${remotes:cs_push}/node.ext.ldap.git pushurl=${remotes:cs_push}/node.ext.ldap.git -yafowil = git ${remotes:cs_push}/yafowil.git pushurl=${remotes:cs_push}/yafowil.git -yafowil.yaml = git ${remotes:cs_push}/yafowil.yaml.git pushurl=${remotes:cs_push}/yafowil.yaml.git -yafowil.webob = git ${remotes:cs_push}/yafowil.webob.git pushurl=${remotes:cs_push}/yafowil.webob.git -yafowil.bootstrap = git ${remotes:cs_push}/yafowil.bootstrap.git pushurl=${remotes:cs_push}/yafowil.bootstrap.git branch=2.0 -yafowil.widget.array = git ${remotes:cs_push}/yafowil.widget.array.git pushurl=${remotes:cs_push}/yafowil.widget.array.git branch=2.0 -yafowil.widget.autocomplete = git ${remotes:cs_push}/yafowil.widget.autocomplete.git pushurl=${remotes:cs_push}/yafowil.widget.autocomplete.git branch=2.0 -yafowil.widget.datetime = git ${remotes:cs_push}/yafowil.widget.datetime.git pushurl=${remotes:cs_push}/yafowil.widget.datetime.git branch=2.0 -yafowil.widget.dict = git ${remotes:cs_push}/yafowil.widget.dict.git pushurl=${remotes:cs_push}/yafowil.widget.dict.git branch=2.0 -yafowil.widget.image = git ${remotes:cs_push}/yafowil.widget.image.git pushurl=${remotes:cs_push}/yafowil.widget.image.git branch=2.0 -cone.tile = git ${remotes:cs_push}/cone.tile.git pushurl=${remotes:cs_push}/cone.tile.git -cone.app = git ${remotes:cs_push}/cone.app.git pushurl=${remotes:cs_push}/cone.app.git branch=1.1 -cone.ugm = git ${remotes:cs_push}/cone.ugm.git pushurl=${remotes:cs_push}/cone.ugm.git branch=1.1 -treibstoff = git ${remotes:cs_push}/treibstoff.git pushurl=${remotes:cs_push}/treibstoff.git -webresource = git ${remotes:cs_push}/webresource.git pushurl=${remotes:cs_push}/webresource.git -bda.intellidatetime = git ${remotes:bda_push}/bda.intellidatetime.git pushurl=${remotes:bda_push}/bda.intellidatetime.git diff --git a/etc/base.cfg b/etc/base.cfg deleted file mode 100644 index aaa8d4a..0000000 --- a/etc/base.cfg +++ /dev/null @@ -1,81 +0,0 @@ -[buildout] -# lxml requirements - apt-get install libxml2-dev libxslt1-dev -extends = - ldap.cfg - versions.cfg - -develop = . - -parts += - instance - test - coverage - testldap - py - -find-links = - http://effbot.org/downloads - -[instance] -recipe = zc.recipe.egg:scripts -dependent-scripts = true -eggs = - ${python-ldap:egg} - waitress - cone.ldap - cone.ugm - -[test] -recipe = zc.recipe.testrunner -eggs = - odict - plumber[test] - yafowil[test] - yafowil.yaml[test] - yafowil.webob - yafowil.widget.array - yafowil.widget.autocomplete - yafowil.widget.datetime - yafowil.widget.dict - yafowil.widget.image - cone.tile[test] - cone.app[test] - cone.ugm[test] - cone.ldap[test] - node.ext.ldap[test] - node.ext.ugm - node -environment = testenv -defaults = ['--auto-color', '--auto-progress'] - -[coverage] -recipe = zc.recipe.egg:scripts -eggs = - coverage - ${test:eggs} -initialization = - import os - os.environ['ADDITIONAL_LDIF_LAYERS'] = '${testenv:ADDITIONAL_LDIF_LAYERS}' - os.environ['SLAPD_BIN'] = '${testenv:SLAPD_BIN}' - os.environ['SLAPD_URIS'] = '${testenv:SLAPD_URIS}' - os.environ['LDAP_DELETE_BIN'] = '${testenv:LDAP_DELETE_BIN}' - os.environ['LDAP_ADD_BIN'] = '${testenv:LDAP_ADD_BIN}' - -[coveralls] -recipe = zc.recipe.egg:scripts -eggs = - coveralls - ${test:eggs} - -[py] -recipe = zc.recipe.egg -eggs = - ${test:eggs} -initialization = - import os - os.environ['ADDITIONAL_LDIF_LAYERS'] = '${testenv:ADDITIONAL_LDIF_LAYERS}' - os.environ['SLAPD_BIN'] = '${testenv:SLAPD_BIN}' - os.environ['SLAPD_URIS'] = '${testenv:SLAPD_URIS}' - os.environ['LDAP_DELETE_BIN'] = '${testenv:LDAP_DELETE_BIN}' - os.environ['LDAP_ADD_BIN'] = '${testenv:LDAP_ADD_BIN}' -interpreter = py diff --git a/etc/ldap.cfg b/etc/ldap.cfg deleted file mode 100644 index 79cc3f8..0000000 --- a/etc/ldap.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[buildout] -parts = - openldap - python-ldap - -[openldap] -# this build needs (on debian based systems): -# apt-get install libsasl2-dev libssl-dev libdb-dev -recipe = zc.recipe.cmmi>=1.1.5 -url = http://mirror.eu.oneandone.net/software/openldap/openldap-release/openldap-2.4.59.tgz -extra_options = --with-sasl --with-tls --enable-slapd=yes --enable-overlays -#osx-env -#environment = -# CPPFLAGS=-I/opt/local/include/db44 -# LDFLAGS=-L/opt/local/lib/db44 - -[python-ldap] -recipe = zc.recipe.egg:custom -egg = python-ldap -include-dirs = - ${openldap:location}/include -library-dirs = - ${openldap:location}/lib -rpath = - ${openldap:location}/lib - -[testenv] -TESTRUN_MARKER = 1 -LDAP_ADD_BIN = ${openldap:location}/bin/ldapadd -LDAP_DELETE_BIN = ${openldap:location}/bin/ldapdelete -SLAPD_BIN = ${openldap:location}/libexec/slapd -SLAPD_URIS = ldap://127.0.0.1:12345 -ADDITIONAL_LDIF_LAYERS = - -[testldap] -recipe = zc.recipe.egg:script -eggs = - node.ext.ldap[test] -initialization = - import os - os.environ['ADDITIONAL_LDIF_LAYERS'] = '${testenv:ADDITIONAL_LDIF_LAYERS}' - os.environ['SLAPD_BIN'] = '${testenv:SLAPD_BIN}' - os.environ['SLAPD_URIS'] = '${testenv:SLAPD_URIS}' - os.environ['LDAP_DELETE_BIN'] = '${testenv:LDAP_DELETE_BIN}' - os.environ['LDAP_ADD_BIN'] = '${testenv:LDAP_ADD_BIN}' diff --git a/etc/versions.cfg b/etc/versions.cfg deleted file mode 100644 index 94ce3bf..0000000 --- a/etc/versions.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[buildout] -versions = versions - -[versions] -zc.buildout = -setuptools = -pyramid = 1.9.4 diff --git a/i18n.sh b/i18n.sh deleted file mode 100755 index 1902556..0000000 --- a/i18n.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# Usage: -# Initial catalog creation (lang is the language identifier): -# ./i18n.sh lang -# Updating translation and compile catalog: -# ./i18n.sh - -# configuration -DOMAIN="cone.ldap" -SEARCH_PATH="src/cone/ldap" -LOCALES_PATH="src/cone/ldap/locale" -# end configuration - -# create locales folder if not exists -if [ ! -d "$LOCALES_PATH" ]; then - echo "Locales directory not exists, create" - mkdir -p "$LOCALES_PATH" -fi - -# create pot if not exists -if [ ! -f "$LOCALES_PATH"/$DOMAIN.pot ]; then - echo "Create pot file" - touch "$LOCALES_PATH"/$DOMAIN.pot -fi - -# no arguments, extract and update -if [ $# -eq 0 ]; then - echo "Extract messages" - pot-create "$SEARCH_PATH" -o "$LOCALES_PATH"/$DOMAIN.pot - - echo "Update translations" - for po in "$LOCALES_PATH"/*/LC_MESSAGES/$DOMAIN.po; do - msgmerge -o "$po" "$po" "$LOCALES_PATH"/$DOMAIN.pot - done - - echo "Compile message catalogs" - for po in "$LOCALES_PATH"/*/LC_MESSAGES/*.po; do - msgfmt -o "${po%.*}.mo" "$po" - done - -# first argument represents language identifier, create catalog -else - cd "$LOCALES_PATH" - mkdir -p $1/LC_MESSAGES - msginit -i $DOMAIN.pot -o $1/LC_MESSAGES/$DOMAIN.po -l $1 -fi diff --git a/include.mk b/include.mk new file mode 100644 index 0000000..97c3330 --- /dev/null +++ b/include.mk @@ -0,0 +1,43 @@ +############################################################################## +# test ldap server +############################################################################## + +.PHONY: start-ldap-base +start-ldap-base: + @(VENV_FOLDER)/bin/testldap start base + +.PHONY: start-ldap-gon-10-10 +start-ldap-gon-10-10: + @(VENV_FOLDER)/bin/testldap start groupOfNames_10_10 + +.PHONY: start-ldap-gon-100-100 +start-ldap-gon-100-100: + @(VENV_FOLDER)/bin/testldap start groupOfNames_100_100 + +.PHONY: start-ldap-posix +start-ldap-posix: + @(VENV_FOLDER)/bin/testldap start posixGroups + +.PHONY: stop-ldap +stop-ldap: + @(VENV_FOLDER)/bin/testldap stop + +############################################################################## +# test instance +############################################################################## + +.PHONY: run-base +run-base: + @(VENV_FOLDER)/bin/pserve cfg/base/ldap_base.ini + +.PHONY: run-gon-10-10 +run-gon-10-10: + @(VENV_FOLDER)/bin/pserve cfg/gon_10_10/ldap_gon_10_10.ini + +.PHONY: run-gon-100-100 +run-gon-100-100: + @(VENV_FOLDER)/bin/pserve cfg/gon_100_100/ldap_gon_100_100.ini + +.PHONY: run-posix +run-posix: + @(VENV_FOLDER)/bin/pserve cfg/posix/ldap_posix.ini diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index b2125ad..0000000 --- a/run_tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -set -e - -export LDAP_ADD_BIN=parts/openldap/bin/ldapadd -export LDAP_DELETE_BIN=parts/openldap/bin/ldapdelete -export SLAPD_BIN=parts/openldap/libexec/slapd -export SLAPD_URIS=ldap://127.0.0.1:12345 -export ADDITIONAL_LDIF_LAYERS= - -./bin/py -m cone.ugm.tests.__init__ -./bin/py -m cone.ldap.tests.__init__ - -unset LDAP_ADD_BIN -unset LDAP_DELETE_BIN -unset SLAPD_BIN -unset SLAPD_URIS -unset ADDITIONAL_LDIF_LAYERS diff --git a/setup.py b/setup.py index 040cc69..1c297bf 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,5 @@ from setuptools import find_packages from setuptools import setup -from setuptools.command.test import test import os @@ -18,13 +17,6 @@ def read_file(name): ]]) -class Test(test): - - def run_tests(self): - from cone.ldap import tests - tests.run_tests() - - setup( name='cone.ldap', version=version, @@ -49,22 +41,9 @@ def run_tests(self): install_requires=[ 'setuptools', 'node.ext.ldap', - 'cone.ugm', - 'yafowil.widget.array', - 'yafowil.widget.dict', - 'yafowil.yaml' + 'cone.ugm' ], extras_require=dict( - test=[ - 'lxml', - 'yafowil.yaml', - 'zope.testrunner' - ] - ), - tests_require=[ - 'lxml', - 'yafowil.yaml', - 'zope.testrunner' - ], - cmdclass=dict(test=Test) + test=['cone.ugm[test]'] + ) ) diff --git a/src/cone/ldap/tests/__init__.py b/src/cone/ldap/tests/__init__.py index fe200ff..e69de29 100644 --- a/src/cone/ldap/tests/__init__.py +++ b/src/cone/ldap/tests/__init__.py @@ -1,32 +0,0 @@ -import sys -import unittest - - -def test_suite(): - from cone.ldap.tests import test_ldap - from cone.ldap.tests import test_settings - from cone.ldap.tests import test_ugm - - from cone.ldap.tests import test_browser_settings - - suite = unittest.TestSuite() - - suite.addTest(unittest.findTestCases(test_ldap)) - suite.addTest(unittest.findTestCases(test_settings)) - suite.addTest(unittest.findTestCases(test_ugm)) - - suite.addTest(unittest.findTestCases(test_browser_settings)) - - return suite - - -def run_tests(): - from zope.testrunner.runner import Runner - - runner = Runner(found_suites=[test_suite()]) - runner.run() - sys.exit(int(runner.failed)) - - -if __name__ == '__main__': - run_tests()