blob: 1893353c037e267f4401e6953264c5005ff61d8f [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
54 flake8-copyright
55 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}
65 codespell {toxinidir}/. --skip {toxinidir}/.git --skip {toxinidir}/.tox \
66 --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
101 juju
102 pytest-operator
103 -r{toxinidir}/requirements.txt
104 -r{toxinidir}/requirements-dev.txt
105commands =
106 pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs}