blob: a8eb8bc9df39404803a6e78c6af373c49e2ec8cc [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]
Dario Faccinf776ffa2023-03-31 16:47:35 +020030basepython = python3.8
Mark Beierl951d90b2022-08-12 11:13:24 -040031setenv =
32 PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
33 PYTHONBREAKPOINT=ipdb.set_trace
34 PY_COLORS=1
35passenv =
36 PYTHONPATH
37 CHARM_BUILD_DIR
38 MODEL_SETTINGS
39
40[testenv:fmt]
41description = Apply coding style standards to code
42deps =
43 black
44 isort
45commands =
46 isort {[vars]all_path}
47 black {[vars]all_path}
48
49[testenv:lint]
50description = Check code against coding style standards
51deps =
52 black
53 flake8
54 flake8-docstrings
Mark Beierl951d90b2022-08-12 11:13:24 -040055 flake8-builtins
56 pylint
57 pyproject-flake8
58 pep8-naming
59 isort
60 codespell
61 yamllint
62 -r{toxinidir}/requirements.txt
63commands =
64 codespell {[vars]lib_path}
Dario Faccind0303f52023-03-24 11:21:19 +010065 codespell {toxinidir} --skip {toxinidir}/.git --skip {toxinidir}/.tox \
Mark Beierl951d90b2022-08-12 11:13:24 -040066 --skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \
67 --skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg
68 pylint -E {[vars]src_path}
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 coverage[toml]
80 -r{toxinidir}/requirements.txt
81commands =
82 coverage run --source={[vars]src_path},{[vars]lib_path} \
83 -m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs}
84 coverage report
85 coverage xml
86
87[testenv:security]
88description = Run security tests
89deps =
90 bandit
91 safety
92commands =
93 bandit -r {[vars]src_path}
94 bandit -r {[vars]lib_path}
95 - safety check
96
97[testenv:integration]
98description = Run integration tests
99deps =
100 pytest
Dario Faccinf88cb4f2023-03-15 14:55:07 +0100101 juju<3
Mark Beierl951d90b2022-08-12 11:13:24 -0400102 pytest-operator
103 -r{toxinidir}/requirements.txt
104 -r{toxinidir}/requirements-dev.txt
105commands =
Dario Faccinf88cb4f2023-03-15 14:55:07 +0100106 pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --cloud microk8s