Exclude API tests from tox.

This commit is contained in:
Malini Kamalambal 2014-07-18 10:22:37 -04:00
parent 009b98f5bf
commit 7d77d5fc82
4 changed files with 80 additions and 5 deletions

View File

@ -0,0 +1,3 @@
# API Tests
git+https://github.com/stackforge/opencafe.git#egg=opencafe

View File

@ -1,6 +1,12 @@
import abc
import jsonschema
import multiprocessing
import six
from oslo.config import cfg
from cafe.drivers.unittest import fixtures
from cdn import bootstrap
from tests.api.utils import client
from tests.api.utils import config
@ -46,3 +52,73 @@ class TestBase(fixtures.BaseTestFixture):
Deletes the added resources
"""
super(TestBase, cls).tearDownClass()
@six.add_metaclass(abc.ABCMeta)
class Server(object):
name = "cdn-api-test-server"
def __init__(self):
self.process = None
@abc.abstractmethod
def get_target(self, conf):
"""Prepares the target object
This method is meant to initialize server's
bootstrap and return a callable to run the
server.
:param conf: The config instance for the
bootstrap class
:returns: A callable object
"""
def is_alive(self):
"""Returns True IFF the server is running."""
if self.process is None:
return False
return self.process.is_alive()
def start(self, conf):
"""Starts the server process.
:param conf: The config instance to use for
the new process
:returns: A `multiprocessing.Process` instance
"""
target = self.get_target(conf)
if not callable(target):
raise RuntimeError("Target not callable")
self.process = multiprocessing.Process(target=target,
name=self.name)
self.process.daemon = True
self.process.start()
# Give it a second to boot.
self.process.join(1)
return self.process
def stop(self):
"""Terminates a process
This method kills a process by
calling `terminate`. Note that
children of this process won't be
terminated but become orphaned.
"""
self.process.terminate()
class CDNServer(Server):
name = "marconi-wsgiref-test-server"
def get_target(self, conf):
server = bootstrap.Bootstrap(conf)
return server.run

View File

@ -16,10 +16,6 @@ testtools>=0.9.32
# Functional Tests
requests>=1.1
# API Tests
git+https://github.com/stackforge/opencafe.git#egg=opencafe
jsonschema
# Test runner
nose
nose-exclude

View File

@ -16,7 +16,7 @@ setenv = VIRTUAL_ENV={envdir}
NOSE_OPENSTACK_STDOUT=1
deps = -r{toxinidir}/requirements/requirements.txt
-r{toxinidir}/tests/test-requirements.txt
commands = nosetests {posargs}
commands = nosetests {posargs} -e api
[tox:jenkins]
downloadcache = ~/cache/pip