| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [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 |
| Patricia Reinoso | 4510195 | 2022-08-30 10:09:15 +0000 | [diff] [blame] | 24 | envlist = lint, unit, integration |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 25 | |
| 26 | [vars] |
| 27 | src_path = {toxinidir}/src/ |
| 28 | tst_path = {toxinidir}/tests/ |
| 29 | lib_path = {toxinidir}/lib/charms/osm_ro |
| Patricia Reinoso | 4510195 | 2022-08-30 10:09:15 +0000 | [diff] [blame] | 30 | all_path = {[vars]src_path} {[vars]tst_path} |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 31 | |
| 32 | [testenv] |
| Dario Faccin | f776ffa | 2023-03-31 16:47:35 +0200 | [diff] [blame] | 33 | basepython = python3.8 |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 34 | setenv = |
| 35 | PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path} |
| 36 | PYTHONBREAKPOINT=ipdb.set_trace |
| 37 | PY_COLORS=1 |
| 38 | passenv = |
| 39 | PYTHONPATH |
| 40 | CHARM_BUILD_DIR |
| 41 | MODEL_SETTINGS |
| 42 | |
| 43 | [testenv:fmt] |
| 44 | description = Apply coding style standards to code |
| 45 | deps = |
| 46 | black |
| 47 | isort |
| 48 | commands = |
| 49 | isort {[vars]all_path} |
| 50 | black {[vars]all_path} |
| 51 | |
| 52 | [testenv:lint] |
| 53 | description = Check code against coding style standards |
| 54 | deps = |
| 55 | black |
| aticig | 5478dd8 | 2022-08-08 15:43:49 +0300 | [diff] [blame] | 56 | flake8==4.0.1 |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 57 | flake8-docstrings |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 58 | flake8-builtins |
| 59 | pyproject-flake8 |
| 60 | pep8-naming |
| 61 | isort |
| 62 | codespell |
| 63 | commands = |
| 64 | # uncomment the following line if this charm owns a lib |
| aticig | 354ca21 | 2022-08-24 01:27:39 +0300 | [diff] [blame] | 65 | codespell {[vars]lib_path} --ignore-words-list=Ro,RO,ro |
| Dario Faccin | d0303f5 | 2023-03-24 11:21:19 +0100 | [diff] [blame] | 66 | codespell {toxinidir} --skip {toxinidir}/.git --skip {toxinidir}/.tox \ |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 67 | --skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \ |
| aticig | 354ca21 | 2022-08-24 01:27:39 +0300 | [diff] [blame] | 68 | --skip {toxinidir}/.mypy_cache --skip {toxinidir}/icon.svg --ignore-words-list=Ro,RO,ro |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 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] |
| 75 | description = Run unit tests |
| 76 | deps = |
| 77 | pytest |
| 78 | pytest-mock |
| 79 | coverage[toml] |
| 80 | -r{toxinidir}/requirements.txt |
| 81 | commands = |
| 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:integration] |
| 88 | description = Run integration tests |
| 89 | deps = |
| 90 | pytest |
| Dario Faccin | 56db64f | 2023-02-16 20:50:38 +0100 | [diff] [blame] | 91 | juju<3 |
| David Garcia | ffab0f1 | 2022-06-27 12:24:36 +0200 | [diff] [blame] | 92 | pytest-operator |
| 93 | -r{toxinidir}/requirements.txt |
| 94 | commands = |
| Patricia Reinoso | 4510195 | 2022-08-30 10:09:15 +0000 | [diff] [blame] | 95 | pytest -v --tb native --ignore={[vars]tst_path}unit --log-cli-level=INFO -s {posargs} --cloud microk8s |