# --------------------------------------------------------------------
# TOX Setup
# --------------------------------------------------------------------

[tox]
envlist =
    cov_clean,
    py27,
    py34,
    cov_report,
    py3kwarn,
    pep8

[testenv]
deps =
    coverage
    mock
commands =
    coverage run -a setup.py test

# --------------------------------------------------------------------
# Coverage
# --------------------------------------------------------------------
[testenv:cov_clean]
whitelist_externals =
    rm
commands =
    coverage erase
    rm -rf htmlcov

[testenv:py27]
whitelist_externals =
    bash
    mv

commands =
    bash -c "if [ ! -d .coverage.data ]; then mkdir .coverage.data; fi"
    coverage run -a setup.py test
    mv {toxinidir}/.coverage {toxinidir}/.coverage.data/.coverage.{envname}

[testenv:py34]
whitelist_externals =
    bash
    mv

commands =
    bash -c "if [ ! -d .coverage.data ]; then mkdir .coverage.data; fi"
    coverage run -a setup.py test
    mv {toxinidir}/.coverage {toxinidir}/.coverage.data/.coverage.{envname}

[testenv:cov_report]
commands =
    coverage combine .coverage.data
    coverage html -d {toxinidir}/htmlcov

[testenv:cov_deploy]
whitelist_externals =
    cp
    sudo

commands =
    sudo cp -a {toxinidir}/htmlcov /var/www/PyOTRS/

# --------------------------------------------------------------------
# Lint
# --------------------------------------------------------------------
[testenv:py3kwarn]
deps =
    py3kwarn
commands =
    py3kwarn pyotrs

[testenv:pep8]
deps =
    flake8
    flake8-quotes

basepython =
    python2.7

commands =
    flake8 \
      --max-complexity=15 \
      --exclude=./build,.venv,.tox,dist,docs,test_pyotrs.py \
      --ignore=Q000 \
      --max-line-length=99 \
      []

# --------------------------------------------------------------------
# Documentation
# --------------------------------------------------------------------
[testenv:docs]
deps =
    jinja2
    pygments
    docutils
    markupsafe
    sphinx
    sphinxcontrib-napoleon
    sphinx_rtd_theme

whitelist_externals =
    rm
    pandoc

basepython =
    python2.7

commands =
    rm -rf {toxinidir}/docs/build
    pandoc -f markdown -t rst -o {toxinidir}/docs/source/changelog_pandoc.txt CHANGELOG.md
    pandoc -f markdown -t rst -o {toxinidir}/docs/source/contributing_pandoc.txt CONTRIBUTING.md
    sphinx-build -b html {toxinidir}/docs/source {toxinidir}/docs/build

[testenv:docs_deploy]
whitelist_externals =
    rm
    cp
    sudo

commands =
    sudo rm -rf /var/www/PyOTRS/docs
    sudo cp -a {toxinidir}/docs/build /var/www/PyOTRS/docs