[tox]
minversion = 2.0
envlist = py27,py35,py36,pep8,docs,linters,lower-constraints
skipsdist = True

[testenv]
usedevelop = True
install_command = pip install {opts} {packages}
setenv =
	VIRTUAL_ENV={envdir}
	PYTHONUNBUFFERED=1
	ROLE_NAME=galera_client
	TEST_IDEMPOTENCE=false
	WORKING_DIR={toxinidir}
	PYTHONWARNINGS=default::DeprecationWarning
deps =
    -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
    -r{toxinidir}/requirements.txt
    -r{toxinidir}/test-requirements.txt
    neutron>=15.0.0,<16.0.0
basepython = python2.7
whitelist_externals =
    sh
    stestr
    rm
    find
commands =
    find . -type f -name "*.pyc" -delete
    rm -Rf .testrepository/times.dbm
    stestr run {posargs}
    stestr slowest
passenv =
    HOME
    USER
    http_proxy
    HTTP_PROXY
    https_proxy
    HTTPS_PROXY
    no_proxy
    NO_PROXY


[testenv:py35]
basepython = python3.5

[testenv:py36]
basepython = python3.6

[testenv:integration]
passenv =
    {[testenv]passenv}
    CONTROLLER_IP
setenv =
    {[testenv]setenv}
    OS_STDOUT_CAPTURE=1
    OS_STDERR_CAPTURE=1
    OS_LOG_CAPTURE=1
commands =
    stestr -c {toxinidir}/networking_opencontrail/tests/integration/.stestr.conf run

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

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

[testenv:cover]
commands = python setup.py test --coverage --coverage-package-name=networking_opencontrail --testr-args='{posargs}'

[testenv:docs]
basepython = python3
commands = python setup.py build_sphinx

[testenv:releasenotes]
basepython = python3
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}

[testenv:ansible]
basepython = python3
deps =
    {[testenv]deps}
    -rhttps://git.openstack.org/cgit/openstack/openstack-ansible/plain/global-requirement-pins.txt
    -rhttps://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt

[testenv:ansible-syntax]
basepython = python3
deps =
    {[testenv:ansible]deps}
commands =
    bash -c "{toxinidir}/tests/common/test-ansible-syntax.sh"

[testenv:ansible-lint]
basepython = python3
deps =
    {[testenv:ansible]deps}
commands =
    bash -c "{toxinidir}/tests/common/test-ansible-lint.sh"

[testenv:linters]
basepython = python3
deps =
    {[testenv:ansible]deps}
commands =
    {[testenv:pep8]commands}
    {[testenv:ansible-lint]commands}
    {[testenv:ansible-syntax]commands}

[flake8]
# E123, E125 skipped as they are invalid PEP-8.
# N340 Check usage of <module>.i18n (and neutron.i18n)
# N341 Check usage of _ from python builtins
# N343 Production code must not import from neutron.tests.*
# N521 Validate that jsonutils module is used instead of json
# N530 No importing of neutron; should be ignored in neutron itself
# N534 Exception messages should be translated
show-source = True
ignore = E123,E125,N340,N341,N343,N521,N530,N534
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build

[hacking]
local-check-factory = neutron.hacking.checks.factory

[testenv:lower-constraints]
basepython = python2.7
setenv = OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:60}
deps =
  -c{toxinidir}/lower-constraints.txt
  -r{toxinidir}/test-requirements.txt
  -r{toxinidir}/requirements.txt
  neutron>=15.0.0,<16.0.0

[testenv:dev]
# run locally (not in the gate) using editable mode
# https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs
commands =
    pip install -q -e "git+https://git.openstack.org/openstack/neutron#egg=neutron"

[testenv:py3-dev]
basepython = python3
commands =
    {[testenv:dev]commands}
    {[testenv]commands}

[testenv:pep8-dev]
basepython = python3
deps =
    {[testenv]deps}
commands =
    {[testenv:dev]commands}
    {[testenv:pep8]commands}
