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


[testenv]
usedevelop = True
install_command =  pip install {opts} {packages}
setenv =
  PYTHONWARNINGS=default::DeprecationWarning
  OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
  OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
  OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
  -r{toxinidir}/requirements.txt
  -r{toxinidir}/test-requirements.txt
whitelist_externals = sh
                      rm
                      find
commands =
  find . -type f -name "*.pyc" -delete
  stestr run --slowest {posargs}
passenv = http_proxy
          HTTP_PROXY
          https_proxy
          HTTPS_PROXY
          no_proxy
          NO_PROXY
          OS_DEBUG
          OS_LOG_CAPTURE
          OS_STDERR_CAPTURE
          OS_STDOUT_CAPTURE
          TRACE_FAILONLY

[testenv:pep8]
basepython = python3
commands =
  flake8
  {[testenv:bandit]commands}

[testenv:py27]
setenv = OS_FAIL_ON_MISSING_DEPS=1

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

[testenv:cover]
basepython = python3
setenv =
  {[testenv]setenv}
  PYTHON=coverage run --source vmware_nsx_tempest --parallel-mode
commands =
  stestr run --no-subunit-trace {posargs}
  coverage combine
  coverage html -d cover
  coverage xml -o cover/coverage.xml

[testenv:docs]
basepython = python3
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
  -r{toxinidir}/requirements.txt
  -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html

[testenv:releasenotes]
basepython = python3
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
  -r{toxinidir}/requirements.txt
  -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

[testenv:debug]
basepython = python3
commands = oslo_debug_helper {posargs}

[flake8]
# E123, E125 skipped as they are invalid PEP-8.

show-source = True
ignore = E125,E126,E128,E129,E265,H305,H307,H404,H405,H904,N530,N531,W504
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject
import-order-style = pep8

[testenv:bandit]
basepython = python3
# B108 hardcoded_tmp_directory - remove when fixed
# B602 subprocess_popen_with_shell_equals_true - removed when fixed
# B605 start_process_with_a_shell - remove when fixed
commands = bandit -r vmware_nsx_tempest_plugin -n 5 -s B108,B602,B605 -ll

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