[tox]
isolated_build = true
envlist =
    docs
    packaging
    py{39,310,311,312}-dj{42}-{sqlite,postgresql,postgis,mysql}
    py{310,311,312}-dj{42,50,51,52}-{sqlite,postgresql,psycopg3,postgis,mysql}
    py{313}-dj{51,52,main}-{sqlite,psycopg3,postgis3,mysql}

[testenv]
deps =
    dj42: django~=4.2.1
    dj50: django~=5.0.2
    dj51: django~=5.1.0
    dj52: django~=5.2.0a1
    djmain: https://github.com/django/django/archive/main.tar.gz
    postgresql: psycopg2-binary
    psycopg3: psycopg[binary]
    postgis: psycopg2-binary
    postgis3: psycopg[binary]
    mysql: mysqlclient
    coverage[toml]
    Jinja2
    html5lib
    pygments
    selenium>=4.8.0
    sqlparse
    django-csp
passenv=
    CI
    COVERAGE_ARGS
    DB_BACKEND
    DB_NAME
    DB_USER
    DB_PASSWORD
    DB_HOST
    DB_PORT
    DISPLAY
    DJANGO_SELENIUM_TESTS
    GITHUB_*
setenv =
    PYTHONPATH = {toxinidir}
    PYTHONWARNINGS = d
    py311-dj42-postgresql: DJANGO_SELENIUM_TESTS = {env:DJANGO_SELENIUM_TESTS:true}
    DB_NAME = {env:DB_NAME:debug_toolbar}
    DB_USER = {env:DB_USER:debug_toolbar}
    DB_HOST = {env:DB_HOST:localhost}
    DB_PASSWORD =  {env:DB_PASSWORD:debug_toolbar}
    DJANGO_SETTINGS_MODULE = tests.settings
allowlist_externals = make
pip_pre = True
commands = python -b -W always -m coverage run -m django test -v2 {posargs:tests}


[testenv:py{39,310,311,312,313}-dj{42,50,51,52,main}-{postgresql,psycopg3}]
setenv =
    {[testenv]setenv}
    DB_BACKEND = postgresql
    DB_PORT = {env:DB_PORT:5432}


[testenv:py{39,310,311,312,313}-dj{42,50,51,52,main}-{postgis,postgis3}]
setenv =
    {[testenv]setenv}
    DB_BACKEND = postgis
    DB_PORT = {env:DB_PORT:5432}


[testenv:py{39,310,311,312,313}-dj{42,50,51,52,main}-mysql]
setenv =
    {[testenv]setenv}
    DB_BACKEND = mysql
    DB_PORT = {env:DB_PORT:3306}


[testenv:py{39,310,311,312,313}-dj{42,50,51,52,main}-sqlite]
setenv =
    {[testenv]setenv}
    DB_BACKEND = sqlite3
    DB_NAME = ":memory:"


[testenv:docs]
commands = make -C {toxinidir}/docs {posargs:spelling}
deps =
    Sphinx
    sphinxcontrib-spelling
    sphinx-rtd-theme

[testenv:packaging]
commands =
    python -m build
    twine check --strict dist/*
deps =
 build
 twine
skip_install = true

[gh-actions]
python =
    3.9: py39
    3.10: py310
    3.11: py311
    3.12: py312
    3.13: py313

[gh-actions:env]
DB_BACKEND =
    mysql: mysql
    postgresql: postgresql
    psycopg3: psycopg3
    postgis: postgis
    postgis3: postgis3
    sqlite3: sqlite
