mgr/dashboard_v2: added tox conf file to run unit tests and linting

Signed-off-by: Ricardo Dias <rdias@suse.com>
This commit is contained in:
Ricardo Dias 2018-02-27 13:21:44 +00:00
parent 59eb1490d8
commit bb352847a8
No known key found for this signature in database
GPG Key ID: 74390C579BD37B68
4 changed files with 86 additions and 8 deletions

12
src/pybind/mgr/dashboard_v2/.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
.coverage
htmlcov
.tox
coverage.xml
junit.xml
# IDE
.vscode
.idea
# virtualenv
venv

View File

@ -18,16 +18,25 @@ The porting of the existing openATTIC functionality will be done in stages. The
work is done by the openATTIC team and is currently tracked in the `openATTIC
JIRA <https://tracker.openattic.org/browse/OP-3039>`_.
Unit Testing
____________
Unit Testing and Linting
________________________
To run the unit tests that reside in :emphasis:`tests/*` do::
We included a tox configuration file that will run the unit tests under
python2 and python3, as well as, linting tools to guarantee the uniformity of
code.
UNITTEST=true py.test --cov=. tests/
To run tox, run the following command in the root directory (where ``tox.ini``
is located) do::
tox
These tests depend on the following python libraries:
* pytest
* pytest-cov
* mock
If you just want to run a single tox environement, for instance only run the
linting tools, do::
tox -e lint
Also don't forget to install tox before running it. To install tox in your
system do::
pip install tox

View File

@ -0,0 +1,29 @@
astroid==1.6.1
attrs==17.4.0
backports.functools-lru-cache==1.4
cheroot==6.0.0
CherryPy==13.1.0
configparser==3.5.0
coverage==4.4.2
enum34==1.1.6
funcsigs==1.0.2
isort==4.2.15
lazy-object-proxy==1.3.1
mccabe==0.6.1
mock==2.0.0
more-itertools==4.1.0
pbr==3.1.1
pluggy==0.6.0
portend==2.2
py==1.5.2
pylint==1.8.2
pytest==3.3.2
pytest-cov==2.5.1
python-bcrypt==0.3.2
pytz==2017.3
singledispatch==3.4.0.3
six==1.11.0
tempora==1.10
tox==2.9.1
virtualenv==15.1.0
wrapt==1.10.11

View File

@ -0,0 +1,28 @@
[tox]
envlist = py27,py3,lint
skipsdist = true
[testenv:py27]
deps=-r{toxinidir}/requirements.txt
setenv=
UNITTEST=true
WEBTEST_INTERACTIVE=false
commands=
{envbindir}/py.test --cov=. --cov-report=term tests/
[testenv:py3]
deps=-r{toxinidir}/requirements.txt
setenv=
UNITTEST=true
WEBTEST_INTERACTIVE=false
commands=
{envbindir}/py.test --cov=. --cov-report=term --cov-report=xml --junitxml=junit.xml tests/
[testenv:lint]
deps=
pylint
pycodestyle
commands=
pylint --rcfile=.pylintrc --jobs=5 .
pycodestyle --max-line-length=100 --exclude=ceph_module_mock.py,python2.7,tests,.tox,venv .