[tox]
minversion = 2.0
envlist = py36,py35,py27,pep8,functional
skipsdist = True

[testenv]

# Note the hash seed is set to 0 until senlin can be tested with a
# random hash seed successfully.
setenv = VIRTUAL_ENV={envdir}
         OS_TEST_PATH=senlin/tests/unit

deps = -r{toxinidir}/test-requirements.txt

usedevelop = True
install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
commands =
    find . -type f -name "*.py[c|o]" -delete
    stestr run {posargs}
    stestr slowest

whitelist_externals = bash
                      find
                      rm

[testenv:debug]
basepython = python3
commands = oslo_debug_helper -t senlin/tests/unit {posargs}

[testenv:debug-py27]
basepython = python2.7
commands = oslo_debug_helper -t senlin/tests/unit {posargs}

[testenv:debug-py35]
basepython = python3.5
commands = oslo_debug_helper -t senlin/tests/unit {posargs}

[testenv:pep8]
basepython = python3
commands =
    flake8 senlin doc/source/ext

[testenv:genconfig]
basepython = python3
envdir = {toxworkdir}/venv
commands =
  {toxinidir}/tools/gen-config

[testenv:genpolicy]
basepython = python3
envdir = {toxworkdir}/venv
commands =
  {toxinidir}/tools/gen-policy

[testenv:venv]
basepython = python3
commands = {posargs}

[testenv:cover]
basepython = python3
setenv =
    {[testenv]setenv}
    PYTHON=coverage run --source senlin --parallel-mode
commands = {toxinidir}/tools/cover.sh {posargs}

[testenv:docs]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands =
  sphinx-build -W -b html doc/source doc/build/html

whitelist_externals = rm

[testenv:releasenotes]
basepython = python3
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

[testenv:api-ref]
basepython = python3
commands =
  sphinx-build -W -b html -d api-ref/build/doctrees api-ref/source api-ref/build/html

[flake8]
# Temporarily disable complaints about docstring for public module/class/method
# H106 Don't put vim configuration in source files
# H203 Use assertIs(Not)None to check for None
ignore = D100,D101,D102,D103,D104,D105,D200,D201,D202,D204,D205,D300,D301,D400,D401,I100,I201
enable-extensions=H106,H203,H204,H205
show-source = true
exclude=.venv,.git,.tox,cover,dist,*lib/python*,*egg,tools,build,releasenotes
max-complexity=20

[hacking]
local-check-factory = senlin.hacking.checks.factory
import_exceptions = senlin.common.i18n

[testenv:bandit]
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = bandit -r senlin -x tests -s B101,B104,B110,B310,B311,B506

[testenv:lower-constraints]
basepython = python3
deps =
  -c{toxinidir}/lower-constraints.txt
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/requirements.txt
