Improve testing

Use stestr for testing
Improve tests hierarchy
Update hacking and pycodestyle versions

Also fix docs and pdf-docs jobs

Change-Id: I4ce5da019251a2a68202f74f706a5bf03e6a22b6
This commit is contained in:
Riccardo Pittau 2021-11-19 10:13:56 +01:00
parent 2d44e35c82
commit 03ebe8810a
14 changed files with 54 additions and 32 deletions

1
.gitignore vendored
View File

@ -37,6 +37,7 @@ AUTHORS
ChangeLog
*.sqlite
*~
.stestr
# Vagrant
.vagrant

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${TESTS_DIR:-./ironic_inspector_client/tests/unit/}
top_dir=./

View File

@ -4,6 +4,9 @@ Ironic Inspector Client
.. image:: https://governance.openstack.org/tc/badges/python-ironic-inspector-client.svg
:target: https://governance.openstack.org/tc/reference/tags/index.html
Overview
--------
This is a client library and tool for `Ironic Inspector`_.
* Free software: Apache license

View File

@ -1,32 +1,29 @@
# -*- coding: utf-8 -*-
#
# -- General configuration ----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinxcontrib.apidoc',
'sphinx.ext.viewcode',
'sphinxcontrib.rsvgconverter',
'openstackdocstheme',
]
openstackdocs_repo_name = 'openstack/python-ironic-inspector-client'
openstackdocs_pdf_link = True
openstackdocs_use_storyboard = True
wsme_protocols = ['restjson']
extensions = [
'sphinxcontrib.apidoc',
'sphinx.ext.viewcode',
'openstackdocstheme',
'cliff.sphinxext'
]
# sphinxcontrib.apidoc options
apidoc_module_dir = '../../ironic_inspector_client'
apidoc_output_dir = 'reference/api'
apidoc_excluded_paths = [
'test/*',
'test',
'tests',
'common/i18n*',
'shell*']
'shell*'
]
apidoc_separate_modules = True
# openstackdocstheme options
openstackdocs_repo_name = 'openstack/python-ironic-inspector-client'
openstackdocs_pdf_link = True
openstackdocs_use_storyboard = True
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@ -50,7 +47,7 @@ add_function_parentheses = True
add_module_names = True
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = 'native'
# -- Options for HTML output --------------------------------------------------

View File

@ -2,7 +2,7 @@
Welcome to Ironic Inspector Client
==================================
.. include:: ../../README.rst
This is a client library and tool for `Ironic Inspector`_.
Contents
========
@ -19,3 +19,6 @@ Indices and tables
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. _Ironic Inspector: https://docs.openstack.org/ironic-inspector/latest/

View File

@ -19,7 +19,7 @@ import unittest
from unittest import mock
import eventlet
eventlet.monkey_patch()
eventlet.monkey_patch() # noqa
from ironic_inspector import introspection_state as istate
from ironic_inspector import process
from ironic_inspector.test import functional

View File

@ -7,3 +7,4 @@ requests-mock>=1.2.0 # Apache-2.0
oslo.concurrency>=3.25.0 # Apache-2.0
osc-lib>=2.1.0 # Apache-2.0
python-openstackclient>=3.12.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0

38
tox.ini
View File

@ -4,25 +4,27 @@ envlist = py3,pep8,functional-py3
ignore_basepython_conflict=true
[testenv]
basepython = python3
install_command = pip install {opts} {packages}
usedevelop = True
basepython = python3
setenv = VIRTUAL_ENV={envdir}
PYTHONDONTWRITEBYTECODE = 1
LANGUAGE=en_US
LC_ALL=en_US.UTF-8
PYTHONWARNINGS=default::DeprecationWarning
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
coverage run --branch --include "ironic_inspector_client*" -m unittest discover ironic_inspector_client.test
coverage report -m --fail-under 90
setenv = PYTHONDONTWRITEBYTECODE=1
stestr run --slowest {posargs}
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
[testenv:pep8]
deps =
hacking>=3.1.0,<4.0.0 # Apache-2.0
hacking>=4.1.0,<5.0.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0
flake8-import-order>=0.17.1 # LGPLv3
pycodestyle>=2.0.0,<2.7.0 # MIT
pycodestyle>=2.0.0,<3.0.0 # MIT
Pygments>=2.2.0 # BSD
commands =
flake8 ironic_inspector_client
@ -32,7 +34,7 @@ commands =
deps = {[testenv]deps}
-r{toxinidir}/functest-requirements.txt
commands =
python -m ironic_inspector_client.test.functional {posargs}
python -m ironic_inspector_client.tests.functional {posargs}
[testenv:functional-py38]
basepython = python3.8
@ -52,6 +54,16 @@ deps =
-r{toxinidir}/doc/requirements.txt
commands = {posargs}
[testenv:cover]
setenv = {[testenv]setenv}
PYTHON=coverage run --source ironic_inspector_client --omit='*tests*' --parallel-mode
commands =
coverage erase
stestr run {posargs}
coverage combine
coverage report --omit='*tests*'
coverage html -d ./cover --omit='*tests*'
[testenv:releasenotes]
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
@ -63,6 +75,8 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/functest-requirements.txt
-r{toxinidir}/test-requirements.txt
-r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html
@ -89,7 +103,7 @@ max-complexity=15
# [H904] Delay string interpolations at logging calls.
enable-extensions=H106,H203,H204,H205,H210,H904
per-file-ignores =
ironic_inspector_client/test/functional.py:E402
ironic_inspector_client/tests/functional.py:E402
[hacking]
import_exceptions = ironic_inspector_client.common.i18n