blob: d08fe86c351337abd5d4dde47e1cfce8bee01acd [file] [log] [blame]
Patricia Reinosod5b463c2023-05-31 08:37:18 +00001# Copyright 2021 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
16[tox]
17skipsdist=True
18skip_missing_interpreters = True
19envlist = lint, unit, analyze, integration
20
21[vars]
22src_path = {toxinidir}/src/
23tst_path = {toxinidir}/tests/
24all_path = {[vars]src_path} {[vars]tst_path}
25
26[testenv]
27basepython = python3.8
28setenv =
29 PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
30 PYTHONBREAKPOINT=ipdb.set_trace
31passenv =
32 PYTHONPATH
33 HOME
34 PATH
35 CHARM_BUILD_DIR
36 MODEL_SETTINGS
37 HTTP_PROXY
38 HTTPS_PROXY
39 NO_PROXY
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
56 flake8-copyright
57 flake8-builtins
58 # prospector[with_everything]
59 pyproject-flake8
60 pep8-naming
61 isort
62 codespell
63 yamllint
64commands =
65 codespell {toxinidir}/*.yaml {toxinidir}/*.ini {toxinidir}/*.md \
66 {toxinidir}/*.toml {toxinidir}/*.txt {toxinidir}/.github
67 # prospector -A -F -T
68 yamllint -d '\{extends: default, ignore: "build\n.tox" \}' .
69 # pflake8 wrapper supports config from pyproject.toml
70 pflake8 {[vars]all_path}
71 isort --check-only --diff {[vars]all_path}
72 black --check --diff {[vars]all_path}
73
74[testenv:unit]
75description = Run unit tests
76deps =
77 pytest
78 pytest-mock
79 pytest-cov
80 coverage[toml]
81 -r{toxinidir}/requirements.txt
82commands =
83 pytest --ignore={[vars]tst_path}integration --cov={[vars]src_path} --cov-report=xml
84 coverage report --omit=tests/*
85
86[testenv:analyze]
87description = Run analize
88deps =
89 pylint==2.10.2
90 -r{toxinidir}/requirements.txt
91commands =
92 pylint -E {[vars]src_path}
93
94[testenv:security]
95description = Run security tests
96deps =
97 bandit
98 safety
99commands =
100 bandit -r {[vars]src_path}
101 - safety check
102
103[testenv:integration]
104description = Run integration tests
105deps =
106 pytest
107 juju<3
108 pytest-operator
109 -r{toxinidir}/requirements.txt
110commands =
111 pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --cloud microk8s