Skip to content

Commit

Permalink
Merge pull request privacyidea#13 from privacyidea/12/update_tests
Browse files Browse the repository at this point in the history
Run relevant tests using tox and travis
  • Loading branch information
cornelinux authored May 7, 2020
2 parents 6f3365c + c64e4db commit 7234e5b
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 62 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.pyc
.idea/
.tox/
venv*/
.coverage
40 changes: 8 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,15 @@ language: python
sudo: false
python:
- 2.7
- 2.6
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8

# command to install dependencies
install:
- "pip install ."
- "pip install -r requirements.txt"
# split the test run according to
# http://blog.travis-ci.com/2012-11-28-speeding-up-your-tests-by-parallelizing-them/
#env:
# - TESTSCRIPT=tests/test_api_system.py
# - TESTSCRIPT=tests/test_api_token.py
# - TESTSCRIPT=tests/test_api_users.py
# - TESTSCRIPT=tests/test_api_validate.py
# - TESTSCRIPT=tests/test_db_model.py
# - TESTSCRIPT=tests/test_lib_apps.py
# - TESTSCRIPT=tests/test_lib_config.py
# - TESTSCRIPT=tests/test_lib_crypto.py
# - TESTSCRIPT=tests/test_lib_importotp.py
# - TESTSCRIPT=tests/test_lib_policy.py
# - TESTSCRIPT=tests/test_lib_realm.py
# - TESTSCRIPT=tests/test_lib_resolver.py
# - TESTSCRIPT=tests/test_lib_tokenclass.py
# - TESTSCRIPT=tests/test_lib_token.py
# - TESTSCRIPT=tests/test_lib_tokens_hotp.py
# - TESTSCRIPT=tests/test_lib_tokens_passwordtoken.py
# - TESTSCRIPT=tests/test_lib_tokens_totp.py
# - TESTSCRIPT=tests/test_lib_tokens_yubikey.py
# - TESTSCRIPT=tests/test_lib_user.py
# - TESTSCRIPT=tests/test_resolver_realm.py
matrix:
allow_failures:
- python: 2.6
- python: 3.4
- "pip install tox-travis"

# command to run tests
#script: "nosetests -v --with-coverage --cover-package=privacyidea $TESTSCRIPT"
script: "py.test tests"
script: "tox"
2 changes: 1 addition & 1 deletion privacyidea_pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def save_auth_item(sqlfile, user, serial, tokentype, authitem):
if authitem:
offline = authitem.get("offline", [{}])[0]
tokenowner = offline.get("username")
for counter, otphash in offline.get("response").iteritems():
for counter, otphash in offline.get("response").items():
# Insert the OTP hash
c.execute("INSERT INTO authitems (counter, user, serial,"
"tokenowner, otp) VALUES (?,?,?,?,?)",
Expand Down
21 changes: 6 additions & 15 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
argparse==1.2.1
cookies==2.2.1
coverage==4.0.3
funcsigs==0.4
mock==1.3.0
passlib==1.6.5
pbr==1.8.1
py==1.4.31
pytest==2.9.0
pytest-cov==2.2.1
pytest-runner==2.7
requests==2.9.1
responses==0.5.1
six==1.10.0
wsgiref==0.1.2
certifi==2020.4.5.1
chardet==3.0.4
idna==2.9
passlib==1.7.2
requests==2.23.0
urllib3==1.25.9
21 changes: 7 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import os
import glob
import sys

from setuptools import setup

#VERSION="2.1dev4"
VERSION="2.11dev0"
VERSION = "2.11dev0"

install_requires = []
# For python 2.6 we need additional dependency importlib
try:
import importlib
except ImportError:
install_requires.append('importlib')
install_requires = [
'requests>=2.23',
'passlib>=1.7.2'
]

setup(
name='privacyidea_pam',
Expand All @@ -34,8 +30,5 @@
"Topic :: System ::"
" Systems Administration :: Authentication/Directory"
],
#message_extractors={'privacyidea': [
# ('**.py', 'python', None),
# ('static/**.html', 'html', {'input_encoding': 'utf-8'})]},
zip_safe=False
)
24 changes: 24 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-r ../requirements.txt
atomicwrites==1.4.0; python_version < '3.0'
attrs==19.3.0
configparser==4.0.2; python_version < '3.0'
contextlib2==0.6.0.post1; python_version < '3.0'
cookies==2.2.1; python_version < '3.0'
funcsigs==1.0.2; python_version < '3.0'
importlib-metadata==1.6.0
mock==3.0.5; python_version < '3.0'
more-itertools==5.0.0; python_version < '3.0'
more-itertools==8.2.0; python_version > '3.0'
packaging==20.3
pathlib2==2.3.5; python_version < '3.0'
pluggy==0.13.1
py==1.8.1
pyparsing==2.4.7
pytest==4.6.9; python_version < '3.0'
pytest==5.4.1; python_version > '3.0'
responses==0.10.14
scandir==1.10.0; python_version < '3.0'
six==1.14.0
wcwidth==0.1.9
zipp==1.2.0; python_version <= '3.5'
zipp==3.1.0; python_version > '3.5'
20 changes: 20 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tox]
envlist = py27,py35,py36,py37,py38
skip_missing_interpreters = true

[gh-actions]
python =
2.7: py27
3.5: py35
3.6: py36
3.7: py37
3.8: py38

[testenv]
# install pytest-cov in the virtualenv where commands will be executed
deps =
-rtests/requirements.txt
pytest-cov
commands =
# NOTE: you can run any command line tool here - not just tests
python -b -m pytest --cov=privacyidea_pam --cov-append

0 comments on commit 7234e5b

Please sign in to comment.