[tox]
minversion = 2.0
envlist = py3-dj111,py3-dj21,py27,py37,pep8
skipsdist = True

[testenv]
usedevelop = True
install_command = pip install {opts} {packages}
deps = -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train}
       -r{toxinidir}/requirements.txt
       -r{toxinidir}/test-requirements.txt
whitelist_externals = /bin/bash
commands = {envpython} {toxinidir}/manage.py test --settings=sahara_dashboard.test.settings --exclude-tag integration {posargs}

[testenv:py27]
setenv =
   DJANGO_SETTINGS_MODULE=sahara_dashboard.test.settings

[testenv:py36]
setenv =
   DJANGO_SETTINGS_MODULE=sahara_dashboard.test.settings

[testenv:py37]
setenv =
   DJANGO_SETTINGS_MODULE=sahara_dashboard.test.settings

[testenv:pep8]
basepython = python3
commands = flake8

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

[testenv:py3-dj111]
basepython = python3
setenv =
   DJANGO_SETTINGS_MODULE=sahara_dashboard.test.settings
commands =
  pip install django>=1.11,<2
  {[testenv]commands}

[testenv:py3-dj21]
basepython = python3
setenv =
   DJANGO_SETTINGS_MODULE=sahara_dashboard.test.settings
commands =
  pip install django>=2.1,<2.2
  {[testenv]commands}

[testenv:py27integration]
basepython = python2.7
passenv = AVCONV_INSTALLED
setenv =
  INTEGRATION_TESTS=1
  SELENIUM_HEADLESS=1
  HORIZON_INTEGRATION_TESTS_CONFIG_FILE={toxinidir}/sahara_dashboard/test/integration_tests/horizon.conf
commands = {envpython} {toxinidir}/manage.py test --settings=sahara_dashboard.test.settings --verbosity 2 --tag integration {posargs}

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

[testenv:cover]
basepython = python3
commands =
  coverage erase
  coverage run {toxinidir}/manage.py test --settings=sahara_dashboard.test.settings --exclude-tag integration {posargs}
  coverage html -d cover
  coverage xml -o cover/coverage.xml

[testenv:debug]
basepython = python3
commands = oslo_debug_helper -t sahara_dashboard/test {posargs}

[flake8]
show-source = True
# E123, E125 skipped as they are invalid PEP-8.
# H405 multi line docstring summary not separated with an empty line
ignore = E123,E125,H405
enable-extensions = H203,H106
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject,tools,.tmp

[testenv:bindep]
basepython = python3
# Do not install any requirements. We want this to be fast and work even if
# system dependencies are missing, since it's used to tell you what system
# dependencies are missing! This also means that bindep must be installed
# separately, outside of the requirements files.
deps = bindep
commands = bindep test

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