blob: 6ef1fe35dbc3dc1bcc75e31dba84ea47fdba73f2 [file] [log] [blame]
Mark Beierl951d90b2022-08-12 11:13:24 -04001#######################################################################################
2# Copyright ETSI Contributors and Others.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#######################################################################################
17
18[tox]
19skipsdist=True
20skip_missing_interpreters = True
21envlist = lint, unit
22
23[vars]
24src_path = {toxinidir}/src/
25tst_path = {toxinidir}/tests/
26lib_path = {toxinidir}/lib/charms/osm_vca_integrator
27all_path = {[vars]src_path} {[vars]tst_path} {[vars]lib_path}
28
29[testenv]
30setenv =
31 PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
32 PYTHONBREAKPOINT=ipdb.set_trace
33 PY_COLORS=1
34passenv =
35 PYTHONPATH
36 CHARM_BUILD_DIR
37 MODEL_SETTINGS
38
39[testenv:fmt]
40description = Apply coding style standards to code
41deps =
42 black
43 isort
44commands =
45 isort {[vars]all_path}
46 black {[vars]all_path}
47
48[testenv:lint]
49description = Check code against coding style standards
50deps =
51 black
52 flake8
53 flake8-docstrings
Mark Beierl951d90b2022-08-12 11:13:24 -040054 flake8-builtins
55 pylint
56 pyproject-flake8
57 pep8-naming
58 isort
59 codespell
60 yamllint
61 -r{toxinidir}/requirements.txt
62commands =
63 codespell {[vars]lib_path}
64 codespell {toxinidir}/. --skip {toxinidir}/.git --skip {toxinidir}/.tox \
65 --skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \
66 --skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg
67 pylint -E {[vars]src_path}
68 # pflake8 wrapper supports config from pyproject.toml
69 pflake8 {[vars]all_path}
70 isort --check-only --diff {[vars]all_path}
71 black --check --diff {[vars]all_path}
72
73[testenv:unit]
74description = Run unit tests
75deps =
76 pytest
77 pytest-mock
78 coverage[toml]
79 -r{toxinidir}/requirements.txt
80commands =
81 coverage run --source={[vars]src_path},{[vars]lib_path} \
82 -m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs}
83 coverage report
84 coverage xml
85
86[testenv:security]
87description = Run security tests
88deps =
89 bandit
90 safety
91commands =
92 bandit -r {[vars]src_path}
93 bandit -r {[vars]lib_path}
94 - safety check
95
96[testenv:integration]
97description = Run integration tests
98deps =
99 pytest
100 juju
101 pytest-operator
102 -r{toxinidir}/requirements.txt
103 -r{toxinidir}/requirements-dev.txt
104commands =
105 pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs}