Unit tests for Feature 10910
[osm/NBI.git] / tox.ini
1 # Copyright 2018 Telefonica S.A.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain 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,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 # implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16
17 [tox]
18 envlist = black, cover, flake8, pylint, safety
19
20 [tox:jenkins]
21 toxworkdir = /tmp/.tox
22
23 [testenv]
24 usedevelop = True
25 basepython = python3.8
26 setenv = VIRTUAL_ENV={envdir}
27 PYTHONDONTWRITEBYTECODE = 1
28 deps = -r{toxinidir}/requirements.txt
29
30 #######################################################################################
31 [testenv:black]
32 deps = black
33 skip_install = true
34 commands =
35 - black --check --diff osm_nbi/
36 - black --check --diff setup.py
37
38
39 #######################################################################################
40 [testenv:cover]
41 deps = {[testenv]deps}
42 -r{toxinidir}/requirements-dev.txt
43 -r{toxinidir}/requirements-test.txt
44 commands =
45 sh -c 'rm -f nosetests.xml'
46 coverage erase
47 nose2 -C --coverage osm_nbi -s osm_nbi/tests
48 coverage report --omit='*tests*'
49 coverage html -d ./cover --omit='*tests*'
50 coverage xml -o coverage.xml --omit=*tests*
51 whitelist_externals = sh
52
53
54 #######################################################################################
55 [testenv:flake8]
56 deps = flake8
57 commands =
58 - flake8 osm_nbi/ setup.py
59
60
61 #######################################################################################
62 [testenv:pylint]
63 deps = {[testenv]deps}
64 -r{toxinidir}/requirements-dev.txt
65 -r{toxinidir}/requirements-test.txt
66 pylint
67 commands =
68 - pylint -E osm_nbi
69
70
71 #######################################################################################
72 [testenv:safety]
73 setenv =
74 LC_ALL=C.UTF-8
75 LANG=C.UTF-8
76 deps = {[testenv]deps}
77 safety
78 commands =
79 - safety check --full-report
80
81
82 #######################################################################################
83 [testenv:pip-compile]
84 deps = pip-tools==6.4.0
85 skip_install = true
86 whitelist_externals = bash
87 [
88 commands =
89 - bash -c "for file in requirements*.in ; do \
90 UNSAFE="" ; \
91 if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
92 pip-compile -rU --no-header $UNSAFE $file ;\
93 out=`echo $file | sed 's/.in/.txt/'` ; \
94 sed -i -e '1 e head -16 tox.ini' $out ;\
95 done"
96
97
98 #######################################################################################
99 [testenv:dist]
100 deps = {[testenv]deps}
101 -r{toxinidir}/requirements-dist.txt
102
103 # In the commands, we copy the requirements.txt to be presented as a source file (.py)
104 # so it gets included in the .deb package for others to consume
105 commands =
106 sh -c 'cp requirements.txt osm_nbi/requirements.txt'
107 python3 setup.py --command-packages=stdeb.command sdist_dsc
108 sh -c 'cd deb_dist/osm-nbi*/ && dpkg-buildpackage -rfakeroot -uc -us'
109 sh -c 'rm osm_nbi/requirements.txt'
110 whitelist_externals = sh
111
112 #######################################################################################
113 [flake8]
114 ignore =
115 W291,
116 W293,
117 W503,
118 E123,
119 E125,
120 E226,
121 E241
122 exclude =
123 .git,
124 __pycache__,
125 .tox,
126 test_mznmodels.py
127 max-line-length = 120
128 show-source = True
129 builtins = _
130