Skip to content

Commit

Permalink
Merge pull request #44 from bluedynamics/unittests
Browse files Browse the repository at this point in the history
Unittests, Python 3
  • Loading branch information
rnixx committed Apr 16, 2019
2 parents b0cf548 + 4f022e0 commit fcf2716
Show file tree
Hide file tree
Showing 57 changed files with 4,703 additions and 462 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/.pydevproject.bak
/.settings
/.vscode/
/py2/
/py3/
/bin/
/coverage/
/develop-eggs/
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ before_install:
install:
- ./bin/buildout -N -t 3 -c travis.cfg
script:
- bin/coverage run --source=./src/node/ext/ldap bin/test
- bin/coverage run --source=./src/node/ext/ldap --omit=./src/node/ext/ldap/main.py bin/test
after_success:
- bin/coveralls
24 changes: 23 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@ History
1.0b9 (unreleased)
------------------

- No changes yet.
- Remove ``smbpasswd`` dependency. Use ``passlib`` instead.
[rnix]

- Use ``bytes_mode=False`` when using ``python-ldap``. This is the default
behavior in python 3 and handles everything as unicode/text except
entry attribute values.
For more details see https://www.python-ldap.org/en/latest/bytes_mode.html
[rnix]

- Add ``ensure_bytes_py2`` in ``node.ext.ldap.base``.
[rnix]

- Rename ``decode_utf8`` to ``ensure_text`` in ``node.ext.ldap.base``.
[rnix]

- Rename ``encode_utf8`` to ``ensure_bytes`` in ``node.ext.ldap.base``.
[rnix]

- Python 3 Support.
[rnix, reinhardt]

- Convert doctests to unittests.
[rnix]


1.0b8 (2018-10-22)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
License
=======

Copyright (c) 2006-2017, BlueDynamics Alliance, Austria, Germany, Switzerland
Copyright (c) 2006-2019, BlueDynamics Alliance, Austria, Germany, Switzerland
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ Dependencies

- python-ldap

- smbpasswd
- passlib

- argparse

Expand Down Expand Up @@ -1175,3 +1175,5 @@ Contributors
- Asko Soukka

- Alex Milosz Sielicki

- Manuel Reinhardt
21 changes: 6 additions & 15 deletions TODO.rst
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
TODO
====

- define what our retry logic should look like, re-think function of session,
communicator and connector. (check ldap.ldapobject.ReconnectLDAPObject)
ideas: more complex retry logic with fallback servers, eg. try immediately
again, if that fails use backup server, then start to probe other server
after a timespan, report status of ldap servers, preferred server,
equal servers, load balancing; Are there ldap load balancers to recommend?

- consider ``search_st`` with timeout.

- investigate ``ReconnectLDAPObject.set_cache_options``

- check/implement silent sort on only the keys ``LDAPNode.sortonkeys``
- investigate ``ReconnectLDAPObject.set_cache_options``.

- node.ext.ldap.filter unicode/utf-8
- check/implement silent sort on only the keys ``LDAPNode.sortonkeys``.

- interactive configuration showing live how many users/groups are found with
the current config and what a selected user/group would look like
the current config and what a selected user/group would look like.

- Configuration validation for UGM. Add some checks in ``Ugm.__init__`` which
tries to block stupid configuration.

- group in group support
- group in group support.

- rework ldap testsetup to allow for multiple servers in order to test with
different overlays it would be nice to start different servers or have one
server with multiple databases. whatever feels better.

- rework tests and ldifs to target isolated aspects
- rework tests and ldifs to target isolated aspects.

- potentially multi-valued attrs always as list!
- potentially multi-valued attrs always as list.

52 changes: 52 additions & 0 deletions base.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[buildout]
extends =
ldap.cfg
versions.cfg
parts +=
coverage
test-coverage
py
pydev
omelette

[test]
recipe = zc.recipe.testrunner
eggs =
${python-ldap:egg}
node[test]
node.ext.ugm
node.ext.ldap[test]

environment = testenv
defaults = ['--auto-color', '--auto-progress']

[coverage]
recipe = zc.recipe.egg
eggs = coverage

[test-coverage]
recipe = collective.recipe.template
input = inline:
#!/bin/bash
${buildout:directory}/bin/coverage run --source=${buildout:directory}/src/node/ext/ldap bin/test
${buildout:directory}/bin/coverage html
${buildout:directory}/bin/coverage report -m --fail-under=90
# Fail (exit status 1) if coverage returns exit status 2 (this happens
# when test coverage is below 100%.
output = ${buildout:directory}/bin/test-coverage
mode = 755

[py]
recipe = zc.recipe.egg
interpreter = py
eggs = ${test:eggs}
scripts =

[pydev]
recipe = pb.recipes.pydev
eggs = ${test:eggs}

[omelette]
recipe = collective.recipe.omelette
eggs = ${test:eggs}
ignore-develop = True
46 changes: 37 additions & 9 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
#!/bin/sh
#!/bin/bash
set -e

# see https://community.plone.org/t/not-using-bootstrap-py-as-default/620
for dir in lib include local bin; do
if [ -d "$dir" ]; then
rm -r "$dir"
function cleanup() {
if [ -e "$1" ]; then
rm -rf $1
fi
done
virtualenv --clear .
./bin/pip install --upgrade pip setuptools zc.buildout
./bin/buildout
}

function create_venv() {
virtualenv --clear --no-site-packages -p $1 $2
}

function copy_config() {
cp ../ldap.cfg .
cp ../versions.cfg .
cp ../base.cfg .
cp ../buildout.cfg .
}

function run_buildout() {
pushd $1
copy_config
./bin/pip install --upgrade pip setuptools zc.buildout
./bin/buildout
popd
}

if [ -x "$(which python)" ]; then
cleanup py2
create_venv python py2
run_buildout py2
fi

if [ -x "$(which python3)" ]; then
cleanup py3
create_venv python3 py3
run_buildout py3
fi
69 changes: 2 additions & 67 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,68 +1,3 @@
[buildout]
extends =
ldap.cfg
versions.cfg
develop = .
parts +=
smbpasswd
coverage
test-coverage
py
pydev
omelette
# dependencytree

[smbpasswd]
recipe = zc.recipe.egg
eggs = smbpasswd
find-links = http://barryp.org/static/software/download/py-smbpasswd/1.0.1/py-smbpasswd-1.0.1.tar.gz

[test]
recipe = zc.recipe.testrunner
eggs =
${python-ldap:egg}
node[test]
node.ext.ugm[test]
node.ext.ldap[test]

environment = testenv
defaults = ['--auto-color', '--auto-progress']

[coverage]
recipe = zc.recipe.egg
eggs = coverage

[test-coverage]
recipe = collective.recipe.template
input = inline:
#!/bin/bash
${buildout:directory}/bin/coverage run --source=${buildout:directory}/src/node/ext/ldap bin/test
${buildout:directory}/bin/coverage html
${buildout:directory}/bin/coverage report -m --fail-under=90
# Fail (exit status 1) if coverage returns exit status 2 (this happens
# when test coverage is below 100%.
output = ${buildout:directory}/bin/test-coverage
mode = 755

[py]
recipe = zc.recipe.egg
interpreter = py
eggs = ${test:eggs}
scripts =

[pydev]
recipe = pb.recipes.pydev
eggs = ${test:eggs}

[omelette]
recipe = collective.recipe.omelette
eggs = ${test:eggs}
ignore-develop = True

#[dependencytree]
#recipe = zc.recipe.egg
#eggs =
# ${test:eggs}
# tl.eggdeps
#ignore-develop = True
#scripts =
extends = base.cfg
develop = ..
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion ldap.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
LDAP
====


LDAP in general
---------------

Expand Down
5 changes: 5 additions & 0 deletions run_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

./$1/bin/coverage run --source=./src/node/ext/ldap --omit=./src/node/ext/ldap/main.py ./$1/bin/test
./$1/bin/coverage report
./$1/bin/coverage html
15 changes: 15 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -e
TEST="bin/test node.ext.ldap"

clear

if [ -x "$(which python)" ]; then
./py2/$TEST
fi

echo ""

if [ -x "$(which python3)" ]; then
./py3/$TEST
fi
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def read_file(name):
install_requires=[
'setuptools',
'python-ldap>=2.4.14',
'smbpasswd',
'passlib',
'argparse',
'bda.cache',
'odict>=1.6.1',
Expand All @@ -57,7 +57,6 @@ def read_file(name):
],
extras_require={
'test': [
'interlude',
'plone.testing',
'zope.configuration',
'zope.testing',
Expand Down
Loading

0 comments on commit fcf2716

Please sign in to comment.