[tox]
envlist = py39,py38,py36,pep8,docs
minversion = 3.18.0
skipsdist = True
ignore_basepython_conflict = True

[testenv]
basepython = python3
usedevelop = True
setenv =
  VIRTUAL_ENV={envdir}
  DJANGO_SETTINGS_MODULE=tacker_horizon.test.settings
deps =
  -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/zed}
  -r{toxinidir}/requirements.txt
  -r{toxinidir}/test-requirements.txt
commands =
  {envpython} {toxinidir}/manage.py test tacker_horizon --settings=tacker_horizon.test.settings --exclude-tag integration {posargs}

[testenv:integration]
# Run integration tests only
passenv =
  DISPLAY
  FFMPEG_INSTALLED
setenv =
  PYTHONHASHSEED=0
  FFMPEG_INSTALLED=True
  INTEGRATION_TESTS=1
  SELENIUM_HEADLESS=False
  HORIZON_INTEGRATION_TESTS_CONFIG_FILE=tacker_horizon/test/integration/horizon.conf
basepython = python3
commands = {envpython} {toxinidir}/manage.py test tacker_horizon --settings=tacker_horizon.test.settings --tag integration {posargs}

[testenv:py36]
basepython = python3.6
commands =
  {envpython} {toxinidir}/manage.py test tacker_horizon --settings=tacker_horizon.test.settings --exclude-tag integration {posargs}

[testenv:py39]
basepython = python3.9
commands =
  {envpython} {toxinidir}/manage.py test tacker_horizon --settings=tacker_horizon.test.settings --exclude-tag integration {posargs}

[testenv:pep8]
basepython = python3
commands = flake8

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

[testenv:pdf-docs]
basepython = python3
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
allowlist_externals =
  make
commands =
  sphinx-build -W -b latex doc/source doc/build/pdf
  make -C doc/build/pdf

[testenv:cover]
basepython = python3
commands =
  coverage erase
  coverage run {toxinidir}/manage.py test tacker_horizon --settings=tacker_horizon.test.settings {posargs}
  coverage xml --omit '.tox/cover/*' -o 'cover/coverage.xml'
  coverage html --omit '.tox/cover/*' -d 'cover/htmlcov'

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

[flake8]
show-source = True
max-complexity = 20

[testenv:makemessages]
commands =
    pybabel extract -F babel-django.cfg -o tacker_horizon/locale/django.pot -k gettext_noop -k gettext_lazy -k ngettext_lazy:1,2 -k ugettext_noop -k ugettext_lazy -k ungettext_lazy:1,2 -k npgettext:1c,2,3 -k pgettext_lazy:1c,2 -k npgettext_lazy:1c,2,3 tacker_horizon
    pybabel extract -F babel-djangojs.cfg -o tacker_horizon/locale/djangojs.pot -k gettext_noop -k gettext_lazy -k ngettext_lazy:1,2 -k ugettext_noop -k ugettext_lazy -k ungettext_lazy:1,2 -k npgettext:1c,2,3 -k pgettext_lazy:1c,2 -k npgettext_lazy:1c,2,3 tacker_horizon

