[tox]
envlist =
    tests
    linting
    coverage
    type_check
skip_missing_interpreters = True
skipsdist = True

[testenv]
commands = python -m pip install --upgrade pip

[testenv:tests]
# the tests environment is called by the Github action that runs the unit tests
deps =
    -rrequirements.txt
    pytest
    pytest-datafiles
    pytest-mock
    pytest-asyncio
    aioresponses
setenv = PYTHONPATH = {toxinidir}/src
commands = python -m pytest --basetemp={envtmpdir} {posargs}

[testenv:linting]
# the linting environment is called by the Github Action that runs the linter
deps =
    -rrequirements.txt
    pylint
    # add your fixtures like e.g. pytest_datafiles here
setenv = PYTHONPATH = {toxinidir}/src
commands =
    pylint edi_energy_scraper
    # add single files (ending with .py) or packages here

[testenv:type_check]
# the type_check environment checks the type hints using mypy
deps =
    -rrequirements.txt
    mypy
commands =
    mypy --show-error-codes src/edi_energy_scraper
    # mypy --show-error-codes unittests # does not work yet, sadly; Some tox/packaging problems
    # add single files (ending with .py) or packages here

[testenv:coverage]
# the coverage environment is called by the Github Action that runs the coverage measurement
deps =
    {[testenv:tests]deps}
    coverage
setenv = PYTHONPATH = {toxinidir}/src
commands =
    coverage run -m pytest --basetemp={envtmpdir} {posargs}
    coverage html --omit .tox/*,unittests/*
    coverage report --fail-under 86 --omit .tox/*,unittests/*


[testenv:dev]
# the dev environment contains everything you need to start developing on your local machine.
deps =
    {[testenv:tests]deps}
    {[testenv:linting]deps}
    {[testenv:type_check]deps}
    {[testenv:coverage]deps}
    black
    isort
    pip-tools
    pre-commit
commands =
    python -m pip install --upgrade pip
    pip-compile requirements.in
    pip install -r requirements.txt
    pre-commit install

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