Normalize unit tests
Change README and test code so that tests are run from the top-level directory. Incorporated instructions for running with tox. Change-Id: I278d29c47906461dfd4a0efbfff441a4cd924cb2
This commit is contained in:
parent
c8d223a1ec
commit
5fedfc403e
|
@ -0,0 +1,7 @@
|
||||||
|
docs/build
|
||||||
|
*.pyc
|
||||||
|
*.egg-info
|
||||||
|
.tox
|
||||||
|
docs/html
|
||||||
|
.coverage
|
||||||
|
cover
|
36
README.rst
36
README.rst
|
@ -23,7 +23,7 @@ Capabilities
|
||||||
* Create Snapshot
|
* Create Snapshot
|
||||||
* Delete Snapshot
|
* Delete Snapshot
|
||||||
* Clone Snapshot
|
* Clone Snapshot
|
||||||
* Get Cluster(s)
|
* Get Cluster(s)
|
||||||
* Get Cluster by Name
|
* Get Cluster by Name
|
||||||
* Get Server(s)
|
* Get Server(s)
|
||||||
* Get Server by Name
|
* Get Server by Name
|
||||||
|
@ -36,24 +36,31 @@ Capabilities
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
::
|
To install::
|
||||||
|
|
||||||
$ python setup.py install
|
$ sudo pip install .
|
||||||
|
|
||||||
|
|
||||||
Unit Tests
|
Unit Tests
|
||||||
==========
|
==========
|
||||||
|
|
||||||
::
|
To run all unit tests::
|
||||||
|
|
||||||
$ pip install nose
|
$ tox -e py27
|
||||||
$ pip install nose-testconfig
|
|
||||||
$ cd test
|
|
||||||
$ nosetests --tc-file config.ini
|
|
||||||
|
|
||||||
|
To run a specific test::
|
||||||
|
|
||||||
|
$ tox -e py27 -- test/file.py:class_name.test_method_name
|
||||||
|
|
||||||
|
To run all unit tests with code coverage::
|
||||||
|
|
||||||
|
$ tox -e cover
|
||||||
|
|
||||||
|
The output of the coverage tests will be placed into the ``coverage`` dir.
|
||||||
|
|
||||||
Folders
|
Folders
|
||||||
=======
|
=======
|
||||||
|
|
||||||
* docs -- contains the documentation.
|
* docs -- contains the documentation.
|
||||||
* hplefthandlient -- the actual client.py library
|
* hplefthandlient -- the actual client.py library
|
||||||
* test -- unit tests
|
* test -- unit tests
|
||||||
|
@ -63,11 +70,18 @@ Folders
|
||||||
Documentation
|
Documentation
|
||||||
=============
|
=============
|
||||||
|
|
||||||
To view the built documentation point your browser to
|
To build the documentation::
|
||||||
|
|
||||||
::
|
$ tox -e docs
|
||||||
|
|
||||||
python-hplefthand/docs/_build/html/index.html
|
To view the built documentation point your browser to::
|
||||||
|
|
||||||
|
docs/html/index.html
|
||||||
|
|
||||||
|
|
||||||
|
Running Simulators
|
||||||
|
==================
|
||||||
|
|
||||||
|
Manually run flask server (when config.ini unit=true)::
|
||||||
|
|
||||||
|
$ python test/HPLeftHandMockServer_flask.py -port 5001 -user <USERNAME> -password <PASSWORD> -debug
|
||||||
|
|
|
@ -48,3 +48,5 @@ Changes in Version 1.0.4
|
||||||
* Change GitHub account reference from WaltHP to hp-storage.
|
* Change GitHub account reference from WaltHP to hp-storage.
|
||||||
* Modify the steps in the Installing from Source section to ensure correct
|
* Modify the steps in the Installing from Source section to ensure correct
|
||||||
installation of dependencies and ordering.
|
installation of dependencies and ordering.
|
||||||
|
* Added tox environments to run tests with code coverage and to generate the documentation
|
||||||
|
* Consolidated the test/README.rst into the top level README.rst and added clarifications
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
Unit tests
|
|
||||||
==========
|
|
||||||
|
|
||||||
1. pip install nose
|
|
||||||
2. pip install nose-testconfig
|
|
||||||
3. use config.ini to configure unit tests
|
|
||||||
3. run tests with nosetests --tc-file config.ini
|
|
||||||
|
|
||||||
Optional alternatives
|
|
||||||
1. Run tests with code and branch coverage:
|
|
||||||
nosetests --with-coverage --cover-package=hplefthandclient --cover-html --tc-file config.ini
|
|
||||||
2. Manually run flask server (when config.ini unit=true):
|
|
||||||
python HPLeftHandMockServer_flask.py -port 5001 -user <USERNAME> -password <PASSWORD> -debug
|
|
||||||
3. Run a specific test
|
|
||||||
nosetests --tc-file config.ini file.py:class_name.test_method_name
|
|
|
@ -26,17 +26,10 @@ from testconfig import config
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
# Add the path for the hplefthandclient modules
|
|
||||||
sys.path.insert(0, os.path.realpath(os.path.abspath('../')))
|
|
||||||
from hplefthandclient import client
|
from hplefthandclient import client
|
||||||
|
|
||||||
TIME = datetime.datetime.now().strftime('%H%M%S')
|
TIME = datetime.datetime.now().strftime('%H%M%S')
|
||||||
|
|
||||||
# pip install nose-testconfig
|
|
||||||
|
|
||||||
# e.g.
|
|
||||||
# nosetests HPLeftHandClient_volume.py -v --tc-file config.ini
|
|
||||||
|
|
||||||
|
|
||||||
class HPLeftHandClientBaseTestCase(unittest.TestCase):
|
class HPLeftHandClientBaseTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,8 @@
|
||||||
|
|
||||||
"""Test class of LeftHand Client handling servers """
|
"""Test class of LeftHand Client handling servers """
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import test_HPLeftHandClient_base
|
import test_HPLeftHandClient_base
|
||||||
|
|
||||||
# Add the path for the hplefthandclient modules
|
|
||||||
sys.path.insert(0, os.path.realpath(os.path.abspath('../')))
|
|
||||||
from hplefthandclient import exceptions
|
from hplefthandclient import exceptions
|
||||||
|
|
||||||
VOLUME_NAME1 = 'VOLUME1_UNIT_TEST_' + test_HPLeftHandClient_base.TIME
|
VOLUME_NAME1 = 'VOLUME1_UNIT_TEST_' + test_HPLeftHandClient_base.TIME
|
||||||
|
|
|
@ -15,13 +15,8 @@
|
||||||
|
|
||||||
"""Test class of LeftHand Client system level APIs """
|
"""Test class of LeftHand Client system level APIs """
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import test_HPLeftHandClient_base
|
import test_HPLeftHandClient_base
|
||||||
|
|
||||||
# Add the path for the hplefthandclient modules
|
|
||||||
sys.path.insert(0, os.path.realpath(os.path.abspath('../')))
|
|
||||||
|
|
||||||
|
|
||||||
class HPLeftHandClientSystemTestCase(test_HPLeftHandClient_base.
|
class HPLeftHandClientSystemTestCase(test_HPLeftHandClient_base.
|
||||||
HPLeftHandClientBaseTestCase):
|
HPLeftHandClientBaseTestCase):
|
||||||
|
|
|
@ -15,12 +15,8 @@
|
||||||
|
|
||||||
"""Test class of LeftHand Client handling volumes & snapshots """
|
"""Test class of LeftHand Client handling volumes & snapshots """
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import test_HPLeftHandClient_base
|
import test_HPLeftHandClient_base
|
||||||
|
|
||||||
# Add the path for the hplefthandclient modules
|
|
||||||
sys.path.insert(0, os.path.realpath(os.path.abspath('../')))
|
|
||||||
from hplefthandclient import exceptions
|
from hplefthandclient import exceptions
|
||||||
|
|
||||||
VOLUME_NAME1 = 'VOLUME1_UNIT_TEST_' + test_HPLeftHandClient_base.TIME
|
VOLUME_NAME1 = 'VOLUME1_UNIT_TEST_' + test_HPLeftHandClient_base.TIME
|
||||||
|
|
9
tox.ini
9
tox.ini
|
@ -1,7 +1,7 @@
|
||||||
[tox]
|
[tox]
|
||||||
minversion = 1.6
|
minversion = 1.6
|
||||||
skipdist = True
|
skipdist = True
|
||||||
envlist = py27,pep8,cover
|
envlist = py27,pep8,cover,docs
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
|
@ -11,15 +11,16 @@ install_command = pip install {opts} {packages}
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands =
|
commands =
|
||||||
nosetests --tc-file={toxinidir}/test/config.ini -v
|
nosetests --tc-file={toxinidir}/config.ini -v {posargs}
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
deps = -r{toxinidir}/requirements.txt
|
deps = -r{toxinidir}/requirements.txt
|
||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands =
|
commands =
|
||||||
nosetests --with-coverage --cover-package=hplefthandclient --cover-html --tc-file={toxinidir}/test/config.ini -v
|
nosetests --with-coverage --cover-package=hplefthandclient --cover-html --tc-file={toxinidir}/config.ini -v {posargs}
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
commands = sphinx-build -b html docs docs/html
|
commands = sphinx-build -b html docs docs/html
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
|
@ -29,4 +30,4 @@ commands =
|
||||||
[flake8]
|
[flake8]
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = E265,E402,E713
|
ignore = E265,E402,E713
|
||||||
exclude = .venv,.git,.tox,dist,doc
|
exclude = .venv,.git,.tox,dist,doc,.ropeproject
|
||||||
|
|
Loading…
Reference in New Issue