[flake8]
max-line-length = 100

[tox]
skipsdist = True
skip_missing_interpreters = True
envlist = fmt, lint, unit, integration

[vars]
all_path = {[vars]src_path} {[vars]tst_path}
src_path = {toxinidir}
tst_path = {toxinidir}/tests/

[testenv]
passenv =
    PYTHONPATH
    CHARM_BUILD_DIR
    MODEL_SETTINGS
    KUBECONFIG
setenv =
    PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
    PYTHONBREAKPOINT=ipdb.set_trace
    PY_COLORS=1

[testenv:fmt]
commands =
    isort {[vars]all_path}
    black {[vars]all_path}
deps =
    -r requirements-fmt.txt
description = Apply coding style standards to code

[testenv:lint]
commands =
    codespell {toxinidir}/. --skip {toxinidir}/.git --skip {toxinidir}/.tox \
      --skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \
      --skip {toxinidir}/.mypy_cache \
      --skip {toxinidir}/icon.svg --skip *.json.tmpl
    # pflake8 wrapper supports config from pyproject.toml
    pflake8 {[vars]all_path}
    isort --check-only --diff {[vars]all_path}
    black --check --diff {[vars]all_path}
deps =
    -r requirements-lint.txt
description = Check code against coding style standards

[testenv:unit]
commands =
    coverage run --source={[vars]src_path} \
        -m pytest -vv --tb native {posargs}
    coverage report
deps =
    -r requirements-unit.txt
description = Run unit tests