blob: 0268da8aa7511d5b78864eaa15b313c3eb0477a3 [file] [log] [blame]
David Garcia516eb472022-06-30 14:37:46 +02001# Copyright 2022 Canonical Ltd.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14#
15# For those usages not covered by the Apache License, Version 2.0 please
16# contact: legal@canonical.com
17#
18# To get in touch with the maintainers, please contact:
19# osm-charmers@lists.launchpad.net
20
21[tox]
22skipsdist=True
23skip_missing_interpreters = True
24envlist = lint, unit
25
26[vars]
27src_path = {toxinidir}/src/
28tst_path = {toxinidir}/tests/
29all_path = {[vars]src_path} {[vars]tst_path}
30
31[testenv]
32setenv =
33 PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
34 PYTHONBREAKPOINT=ipdb.set_trace
35 PY_COLORS=1
36passenv =
37 PYTHONPATH
38 CHARM_BUILD_DIR
39 MODEL_SETTINGS
40
41[testenv:fmt]
42description = Apply coding style standards to code
43deps =
44 black
45 isort
46commands =
47 isort {[vars]all_path}
48 black {[vars]all_path}
49
50[testenv:lint]
51description = Check code against coding style standards
52deps =
53 black
54 flake8
55 flake8-docstrings
David Garcia516eb472022-06-30 14:37:46 +020056 flake8-builtins
57 pyproject-flake8
58 pep8-naming
59 isort
60 codespell
61commands =
62 codespell {toxinidir}/. --skip {toxinidir}/.git --skip {toxinidir}/.tox \
63 --skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \
64 --skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg
65 # pflake8 wrapper supports config from pyproject.toml
66 pflake8 {[vars]all_path}
67 isort --check-only --diff {[vars]all_path}
68 black --check --diff {[vars]all_path}
69
70[testenv:unit]
71description = Run unit tests
72deps =
73 pytest
74 pytest-mock
75 coverage[toml]
76 -r{toxinidir}/requirements.txt
77commands =
78 coverage run --source={[vars]src_path} \
79 -m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs}
80 coverage report
81 coverage xml
82
83[testenv:integration]
84description = Run integration tests
85deps =
86 pytest
87 juju
88 pytest-operator
89 -r{toxinidir}/requirements.txt
90commands =
91 pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs}