[tox]
minversion = 1.6
envlist = py35,py27,pypy,pep8
skipsdist = True

[testenv]
usedevelop = True
setenv =
   OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
   OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
   OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
   PYTHONWARNINGS=default::DeprecationWarning
deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/rocky}
       -r{toxinidir}/requirements.txt
       -r{toxinidir}/test-requirements.txt
commands = stestr run {posargs}

[testenv:common]
# Fake job to define environment variables shared between dsvm/non-dsvm jobs
setenv = OS_TEST_TIMEOUT=180
commands = false

[testenv:dsvm]
setenv = OS_FAIL_ON_MISSING_DEPS=1
         OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs}

[testenv:functional]
basepython = python2.7
setenv = {[testenv]setenv}
         {[testenv:common]setenv}
         OS_TEST_PATH=./networking_bagpipe/tests/functional
         OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs}
deps =
  {[testenv]deps}
  -r{toxinidir}/networking_bagpipe/tests/functional/requirements.txt

[testenv:dsvm-functional]
basepython = python2.7
setenv = {[testenv:functional]setenv}
         {[testenv:dsvm]setenv}
sitepackages=True
deps =
  {[testenv:functional]deps}
commands = stestr run {posargs}

[testenv:dsvm-fullstack]
setenv = {[testenv]setenv}
         {[testenv:common]setenv}
         {[testenv:dsvm]setenv}
         # workaround for DB teardown lock contention (bug/1541742)
         OS_TEST_TIMEOUT=600
         OS_TEST_PATH=./networking_bagpipe/tests/fullstack
deps =
  {[testenv:functional]deps}

[testenv:releasenotes]
commands = sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

[testenv:pep8]
commands =
    flake8
    pylint -E --rcfile=.pylintrc --output-format=colorized {posargs:networking_bagpipe}
    neutron-db-manage --subproject networking-bagpipe --database-connection sqlite:// check_migration
    {[testenv:genconfig]commands}

[testenv:venv]
commands = {posargs}

[testenv:cover]
basepython = python2.7
setenv =
    PYTHON = coverage run --source networking_bagpipe --parallel-mode
commands =
    stestr run {posargs}
    coverage combine
    coverage html -d cover
    coverage xml -o cover/coverage.xml

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

[testenv:debug]
commands = oslo_debug_helper {posargs}

[testenv:genconfig]
commands = {toxinidir}/tools/generate_config_file_samples.sh
whitelist_externals = sh

[flake8]
show-source = True
enable-extensions = H203,H904
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,tools,.tmp,bagpipe-bgp/*

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