[tox]
envlist = py37,pep8,py27-local,py36-local,py3-dj111-local,eslint,karma-local,docs-local,releasenotes,lower-constraints-local
minversion = 2.3.2
skipsdist = True

[testenv]
usedevelop = True
deps =
  -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
  -r{toxinidir}/requirements.txt
  -r{toxinidir}/test-requirements.txt
commands = python manage.py test {posargs} --settings=senlin_dashboard.test.settings

# For installation of horizon on local
# NOTICE: this tox.ini requires horizon repository cloned in sibling directory.
[testenv:hz-local]
commands =
  pip install -e ../horizon

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

[testenv:pep8]
basepython = python3
commands = flake8

[flake8]
show-source = True
# F405 TEMPLATES may be undefined, or defined from star imports
# (because it is not easy to avoid this in openstack_dashboard.test.settings)
ignore = F405
enable-extensions = H203,H106
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject,tools,node_modules

[testenv:cover]
basepython = python3
commands = python setup.py testr --coverage --testr-args='{posargs}'

# NOTE(shu-mutow): On CI infra, horizon will be installed
# according to job setting. but on local, we need to install
# horizon from master branch.
[testenv:py27-local]
basepython = python2.7
commands =
  {[testenv:hz-local]commands}
  {[testenv]commands}

[testenv:py36-local]
basepython = python3.6
commands =
  {[testenv:hz-local]commands}
  {[testenv]commands}

[testenv:py3-dj111]
basepython = python3
commands =
  pip install django>=1.11,<2
  {[testenv]commands}

[testenv:py3-dj111-local]
basepython = python3
commands =
  {[testenv:hz-local]commands}
  pip install django>=1.11,<2
  {[testenv]commands}

[testenv:eslint]
basepython = python3
whitelist_externals =
  npm
commands =
  npm install
  npm run lint

# NOTE(shu-mutow): The "postinstall" script on package.json will install horizon
# from master branch into py35 environment for testing javascripts.
# Horizon from master is needed to be cloned into ../horizon on both local and CI.
[testenv:karma]
basepython = python3
whitelist_externals =
  {[testenv:eslint]whitelist_externals}
commands =
  npm install
  npm run test

[testenv:karma-local]
basepython = python3
whitelist_externals =
  {[testenv:eslint]whitelist_externals}
commands =
  {[testenv:karma]commands}

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

[testenv:docs-local]
basepython = python3
deps =
  {[testenv:docs]deps}
commands=
  {[testenv:hz-local]commands}
  {[testenv:docs]commands}

[testenv:releasenotes]
basepython = python3
deps =
  {[testenv:docs]deps}
commands =
  sphinx-build -a -E -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html

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

[testenv:makemessages]
basepython = python3
commands =
    pybabel extract -F babel-django.cfg -o senlin_dashboard/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 senlin_dashboard
    pybabel extract -F babel-djangojs.cfg -o senlin_dashboard/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 senlin_dashboard


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

[testenv:lower-constraints-local]
basepython = python3
deps =
  {[testenv:lower-constraints]deps}
commands =
  {[testenv:hz-local]commands}
  {[testenv]commands}
