# Authors:
#     Christian Heimes <cheimes@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2015 Red Hat, Inc.
# All rights reserved.
#

[tox]
envlist = py27,py35,py36,,pep8,pep8py3,lint,lint3,docs
skip_missing_interpreters = true

[testenv:deps]
deps =
    lxml
    pyldap
    python-nss
    requests
    six

[testenv]
# force installation of sphinx and lint in virtual env, otherwise
# the command pick up the `pki` package from the system's site packages.
install_command = pip install {opts} --force-reinstall --upgrade {packages}
deps =
    {[testenv:deps]deps}
    pytest
sitepackages = True
commands =
    {envpython} {envbindir}/pkidestroy --help
    {envpython} {envbindir}/pkispawn --help
    {envpython} {envbindir}/pki-server --help
    {envpython} {envbindir}/pki-server-upgrade --help
    {envpython} {envbindir}/pki-upgrade --help
    py.test --capture=no --strict tests/python {posargs}

[testenv:lint]
basepython = python2.7
deps =
    {[testenv:deps]deps}
    pylint
commands =
    {envpython} {toxinidir}/pylint-build-scan.py tox

[testenv:lint3]
basepython = python3
deps =
    {[testenv:deps]deps}
    pylint
commands =
    {envpython} {toxinidir}/pylint-build-scan.py tox

[testenv:pep8]
basepython = python2.7
sitepackages = False
deps =
    {[testenv:deps]deps}
    flake8
    # flake8-import-order
    pep8-naming
commands =
    flake8 {posargs}

[testenv:pep8py3]
basepython = python3
sitepackages = False
deps =
    {[testenv:deps]deps}
    flake8
    # flake8-import-order
    pep8-naming
commands =
    flake8 {posargs}

[testenv:docs]
basepython = python2.7
changedir = base/common/python
deps =
    sphinx < 1.3.0
commands =
    sphinx-build -v -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[pytest]
python_files = tests/python/*.py

[flake8]
ignore = N802,N806,N812
exclude = .tox,*.egg,dist,build,conf.py,tests/dogtag/*,.git
filename = *.py,pkidestroy,pki-upgrade,pki-server,pki-server-upgrade,pkispawn,[0-9][0-9]-*
show-source = true
max-line-length = 99
# application-import-names = pki
