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:
Gary W. Smith 2015-02-23 11:05:11 -08:00
parent c8d223a1ec
commit 5fedfc403e
10 changed files with 39 additions and 50 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
docs/build
*.pyc
*.egg-info
.tox
docs/html
.coverage
cover

View File

@ -23,7 +23,7 @@ Capabilities
* Create Snapshot
* Delete Snapshot
* Clone Snapshot
* Get Cluster(s)
* Get Cluster(s)
* Get Cluster by Name
* Get Server(s)
* Get Server by Name
@ -36,24 +36,31 @@ Capabilities
Installation
============
::
To install::
$ python setup.py install
$ sudo pip install .
Unit Tests
==========
::
To run all unit tests::
$ pip install nose
$ pip install nose-testconfig
$ cd test
$ nosetests --tc-file config.ini
$ tox -e py27
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
=======
* docs -- contains the documentation.
* hplefthandlient -- the actual client.py library
* test -- unit tests
@ -63,11 +70,18 @@ Folders
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

View File

@ -48,3 +48,5 @@ Changes in Version 1.0.4
* Change GitHub account reference from WaltHP to hp-storage.
* Modify the steps in the Installing from Source section to ensure correct
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

View File

@ -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

View File

@ -26,17 +26,10 @@ from testconfig import config
from urlparse import urlparse
import datetime
# Add the path for the hplefthandclient modules
sys.path.insert(0, os.path.realpath(os.path.abspath('../')))
from hplefthandclient import client
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):

View File

@ -15,12 +15,8 @@
"""Test class of LeftHand Client handling servers """
import sys
import os
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
VOLUME_NAME1 = 'VOLUME1_UNIT_TEST_' + test_HPLeftHandClient_base.TIME

View File

@ -15,13 +15,8 @@
"""Test class of LeftHand Client system level APIs """
import sys
import os
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.
HPLeftHandClientBaseTestCase):

View File

@ -15,12 +15,8 @@
"""Test class of LeftHand Client handling volumes & snapshots """
import sys
import os
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
VOLUME_NAME1 = 'VOLUME1_UNIT_TEST_' + test_HPLeftHandClient_base.TIME

View File

@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipdist = True
envlist = py27,pep8,cover
envlist = py27,pep8,cover,docs
[testenv]
setenv = VIRTUAL_ENV={envdir}
@ -11,15 +11,16 @@ install_command = pip install {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
nosetests --tc-file={toxinidir}/test/config.ini -v
nosetests --tc-file={toxinidir}/config.ini -v {posargs}
[testenv:cover]
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
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]
deps = -r{toxinidir}/test-requirements.txt
commands = sphinx-build -b html docs docs/html
[testenv:pep8]
@ -29,4 +30,4 @@ commands =
[flake8]
show-source = True
ignore = E265,E402,E713
exclude = .venv,.git,.tox,dist,doc
exclude = .venv,.git,.tox,dist,doc,.ropeproject