# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic/
envlist =
  update-locales
  py3
  py3-oldstable
  py3-stable
  check-migrations
  code-style
  pylint
labels =
  jenkins = update-locales,py3-oldstable,check-migrations,code-style,pylint

[testenv]
setenv =

  NUMPROCESSES={env:NUMPROCESSES:1}

  AUTHENTIC2_SETTINGS_FILE=tests/settings.py
  DJANGO_SETTINGS_MODULE=authentic2.settings

  TESTS=tests/

  DB_ENGINE=django.db.backends.postgresql_psycopg2
  SETUPTOOLS_USE_DISTUTILS=stdlib

  JUNIT={tty::-o junit_suite_name={envname} --junit-xml=junit-{envname}.xml}
  COVERAGE={tty::--cov --cov-append --cov-report xml --cov-report html --cov-context=test --cov-config=tox.ini}
  fast: FAST=--nomigrations
  reusedb: REUSEDB=--reuse-db
passenv=
  BRANCH_NAME
  # support for pg_virtualenv
  PGPORT
  PGHOST
  PGUSER
  PGPASSWORD
  # to customize pytest running in your locale environment, ex.:
  # export PYTESTOPTIONS=--sw
  PYTESTOPTIONS
deps = 
  pip > 9
  stable: django>=3.2.12,<3.3
  stable: django-model-utils>=4.2,<4.3
  stable: django-select2>=7.7,<7.8
  stable: django-tables2==2.4.1
  stable: django-import-export>=3.0,<3.1
  oldstable: django-import-export>=2.5,<2.6
  psycopg2-binary
  coverage
  pytest-cov
  pytest-django
  pytest-random
  pytest-xdist
  mock<4
  pytest!=5.3.3
  lxml
  cssselect
  django-webtest
  Markdown<3
  WebTest
  pyquery
  pytz
  pytest-freezegun
  faker
  uwsgidecorators
  enum34<=1.1.6
  ldaptools>=0.24
  numpy
  django-filter
  responses
  stable: djangorestframework>=3.14,<3.15
  oldstable: djangorestframework>=3.12,<3.13
  stable: jwcrypto>=1.1,<1.3
  oldstable: jwcrypto<0.9
usedevelop = True
allowlist_externals =
  ./getlasso3.sh
commands =
  ./getlasso3.sh
  py.test {env:PYTESTOPTIONS:} {env:FAST:} {env:REUSEDB:} {env:COVERAGE:} {env:JUNIT:} {env:SW:} {posargs:{env:TESTS} --numprocesses {env:NUMPROCESSES:1} --random-group}

[testenv:check-migrations]
basepython = python3
usedevelop = True
setenv =
  DJANGO_SETTINGS_MODULE=authentic2.settings
  SETUPTOOLS_USE_DISTUTILS=stdlib
deps =
    psycopg2-binary
allowlist_externals =
  ./getlasso3.sh
  ./check-migrations.sh
commands =
  ./getlasso3.sh
  ./check-migrations.sh

[testenv:pylint]
basepython = python3
setenv =
  DJANGO_SETTINGS_MODULE=authentic2.settings
  SETUPTOOLS_USE_DISTUTILS=stdlib
  NUMPROCESSES={env:NUMPROCESSES:1}
deps =
    pylint
    astroid
    pylint-django
    psycopg2-binary
    django_webtest
    faker
    lxml
    ldaptools
    pytest
    uwsgidecorators
    pyquery
    numpy
    responses
allowlist_externals =
  ./getlasso3.sh
  ./pylint.sh
commands =
    ./getlasso3.sh
    ./pylint.sh {posargs:tests/ src/}

[testenv:manage]
usedevelop = True
setenv =
  DJANGO_SETTINGS_MODULE=authentic2.settings
  AUTHENTIC2_SETTINGS_FILE=local_settings.py
deps =
  psycopg2-binary
  django-debug-toolbar
  ipython
  ipdb
allowlist_externals =
  ./getlasso3.sh
  ./manage.py
commands =
    ./getlasso3.sh
    ./manage.py {posargs:--help}


[testenv:update-locales]
usedevelop = True
setenv =
  DJANGO_SETTINGS_MODULE=authentic2.settings
deps =
  psycopg2-binary
allowlist_externals =
  ./getlasso3.sh
  ./manage.py
commands =
    ./getlasso3.sh
    ./manage.py makemessages -l fr -i tests
    ./manage.py compilemessages


[testenv:code-style]
skip_install = true
deps =
  pre-commit
commands =
  pre-commit run --all-files --show-diff-on-failure

[pytest]
filterwarnings =
  ignore
  once:::authentic2.*
  error:.*please use dns.resolver.resolve:DeprecationWarning:
  error:.*Passing None for the middleware get_response argument is deprecated.*::
  error:.*ANTIALIAS is deprecated and will be removed in Pillow 10::
  error:.*LANCZOS.*Pillow 10::
junit_family=xunit2

[coverage:run]
source =
    src
    tests
branch = True

[coverage:html]
show_contexts = True
