| beierlm | 8ea1f37 | 2022-06-30 09:02:30 -0400 | [diff] [blame] | 1 | # 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] |
| 22 | skipsdist=True |
| 23 | skip_missing_interpreters = True |
| Dario Faccin | 4734de1 | 2023-02-15 10:52:55 +0100 | [diff] [blame] | 24 | envlist = lint, unit, integration |
| beierlm | 8ea1f37 | 2022-06-30 09:02:30 -0400 | [diff] [blame] | 25 | |
| 26 | [vars] |
| 27 | src_path = {toxinidir}/src/ |
| 28 | tst_path = {toxinidir}/tests/ |
| 29 | all_path = {[vars]src_path} {[vars]tst_path} |
| 30 | |
| 31 | [testenv] |
| Dario Faccin | f776ffa | 2023-03-31 16:47:35 +0200 | [diff] [blame] | 32 | basepython = python3.8 |
| beierlm | 8ea1f37 | 2022-06-30 09:02:30 -0400 | [diff] [blame] | 33 | setenv = |
| 34 | PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path} |
| 35 | PYTHONBREAKPOINT=ipdb.set_trace |
| 36 | PY_COLORS=1 |
| 37 | passenv = |
| 38 | PYTHONPATH |
| 39 | CHARM_BUILD_DIR |
| 40 | MODEL_SETTINGS |
| 41 | |
| 42 | [testenv:fmt] |
| 43 | description = Apply coding style standards to code |
| 44 | deps = |
| 45 | black |
| 46 | isort |
| 47 | commands = |
| 48 | isort {[vars]all_path} |
| 49 | black {[vars]all_path} |
| 50 | |
| 51 | [testenv:lint] |
| 52 | description = Check code against coding style standards |
| 53 | deps = |
| 54 | black |
| 55 | flake8 |
| 56 | flake8-docstrings |
| beierlm | 8ea1f37 | 2022-06-30 09:02:30 -0400 | [diff] [blame] | 57 | flake8-builtins |
| 58 | pyproject-flake8 |
| 59 | pep8-naming |
| 60 | isort |
| 61 | codespell |
| 62 | commands = |
| Dario Faccin | d0303f5 | 2023-03-24 11:21:19 +0100 | [diff] [blame] | 63 | codespell {toxinidir} --skip {toxinidir}/.git --skip {toxinidir}/.tox \ |
| beierlm | 8ea1f37 | 2022-06-30 09:02:30 -0400 | [diff] [blame] | 64 | --skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \ |
| 65 | --skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg |
| 66 | # pflake8 wrapper supports config from pyproject.toml |
| 67 | pflake8 {[vars]all_path} |
| 68 | isort --check-only --diff {[vars]all_path} |
| 69 | black --check --diff {[vars]all_path} |
| 70 | |
| 71 | [testenv:unit] |
| 72 | description = Run unit tests |
| 73 | deps = |
| 74 | pytest |
| 75 | pytest-mock |
| 76 | coverage[toml] |
| 77 | -r{toxinidir}/requirements.txt |
| 78 | commands = |
| 79 | coverage run --source={[vars]src_path} \ |
| 80 | -m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs} |
| 81 | coverage report |
| 82 | coverage xml |
| 83 | |
| 84 | [testenv:integration] |
| 85 | description = Run integration tests |
| 86 | deps = |
| 87 | pytest |
| Dario Faccin | 4734de1 | 2023-02-15 10:52:55 +0100 | [diff] [blame] | 88 | juju<3 |
| beierlm | 8ea1f37 | 2022-06-30 09:02:30 -0400 | [diff] [blame] | 89 | pytest-operator |
| 90 | -r{toxinidir}/requirements.txt |
| 91 | commands = |
| Dario Faccin | 4734de1 | 2023-02-15 10:52:55 +0100 | [diff] [blame] | 92 | pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --cloud microk8s |