Switch to testr / testtools / fixtures, remove nose

* This also fixes us up to hacking standards
* Remove assertGreater* usage in favor of assertEqual py26..
* assertEquals > assertEqual

Change-Id: I8083c96da09897d650ca6fffc0e340d9c057db8d
This commit is contained in:
Endre Karlson 2013-11-18 13:53:30 +01:00
parent 20fd3a90fb
commit c81d5f36c2
46 changed files with 906 additions and 239 deletions

1
.gitignore vendored
View File

@ -23,3 +23,4 @@ designate/versioninfo
*.DS_Store *.DS_Store
*.idea *.idea
/bind9 /bind9
.testrepository/*

4
.testr.conf Normal file
View File

@ -0,0 +1,4 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} ${PYTHON:-python} -m subunit.run discover -t ./ ./ $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -24,7 +24,6 @@
"*.psd", "*.psd",
"*.db", "*.db",
".vagrant", ".vagrant",
".noseids"
], ],
"folder_exclude_patterns": "folder_exclude_patterns":
[ [

View File

@ -0,0 +1,139 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
import errno
import os
import tempfile
from designate.openstack.common import excutils
from designate.openstack.common.gettextutils import _ # noqa
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__)
_FILE_CACHE = {}
def ensure_tree(path):
"""Create a directory (and any ancestor directories required)
:param path: Directory to create
"""
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST:
if not os.path.isdir(path):
raise
else:
raise
def read_cached_file(filename, force_reload=False):
"""Read from a file if it has been modified.
:param force_reload: Whether to reload the file.
:returns: A tuple with a boolean specifying if the data is fresh
or not.
"""
global _FILE_CACHE
if force_reload and filename in _FILE_CACHE:
del _FILE_CACHE[filename]
reloaded = False
mtime = os.path.getmtime(filename)
cache_info = _FILE_CACHE.setdefault(filename, {})
if not cache_info or mtime > cache_info.get('mtime', 0):
LOG.debug(_("Reloading cached file %s") % filename)
with open(filename) as fap:
cache_info['data'] = fap.read()
cache_info['mtime'] = mtime
reloaded = True
return (reloaded, cache_info['data'])
def delete_if_exists(path, remove=os.unlink):
"""Delete a file, but ignore file not found error.
:param path: File to delete
:param remove: Optional function to remove passed path
"""
try:
remove(path)
except OSError as e:
if e.errno != errno.ENOENT:
raise
@contextlib.contextmanager
def remove_path_on_error(path, remove=delete_if_exists):
"""Protect code that wants to operate on PATH atomically.
Any exception will cause PATH to be removed.
:param path: File to work with
:param remove: Optional function to remove passed path
"""
try:
yield
except Exception:
with excutils.save_and_reraise_exception():
remove(path)
def file_open(*args, **kwargs):
"""Open file
see built-in file() documentation for more details
Note: The reason this is kept in a separate module is to easily
be able to provide a stub module that doesn't alter system
state at all (for unit tests)
"""
return file(*args, **kwargs)
def write_to_tempfile(content, path=None, suffix='', prefix='tmp'):
"""Create temporary file or use existing file.
This util is needed for creating temporary file with
specified content, suffix and prefix. If path is not None,
it will be used for writing content. If the path doesn't
exist it'll be created.
:param content: content for temporary file.
:param path: same as parameter 'dir' for mkstemp
:param suffix: same as parameter 'suffix' for mkstemp
:param prefix: same as parameter 'prefix' for mkstemp
For example: it can be used in database tests for creating
configuration files.
"""
if path:
ensure_tree(path)
(fd, path) = tempfile.mkstemp(suffix=suffix, dir=path, prefix=prefix)
try:
os.write(fd, content)
finally:
os.close(fd)
return path

View File

@ -0,0 +1,46 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2013 Mirantis, Inc.
# Copyright 2013 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
from oslo.config import cfg
import six
class Config(fixtures.Fixture):
"""Override some configuration values.
The keyword arguments are the names of configuration options to
override and their values.
If a group argument is supplied, the overrides are applied to
the specified configuration option group.
All overrides are automatically cleared at the end of the current
test by the reset() method, which is registered by addCleanup().
"""
def __init__(self, conf=cfg.CONF):
self.conf = conf
def setUp(self):
super(Config, self).setUp()
self.addCleanup(self.conf.reset)
def config(self, **kw):
group = kw.pop('group', None)
for k, v in six.iteritems(kw):
self.conf.set_override(k, v, group)

View File

@ -0,0 +1,53 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
from designate.openstack.common.lockutils import lock
class LockFixture(fixtures.Fixture):
"""External locking fixture.
This fixture is basically an alternative to the synchronized decorator with
the external flag so that tearDowns and addCleanups will be included in
the lock context for locking between tests. The fixture is recommended to
be the first line in a test method, like so::
def test_method(self):
self.useFixture(LockFixture)
...
or the first line in setUp if all the test methods in the class are
required to be serialized. Something like::
class TestCase(testtools.testcase):
def setUp(self):
self.useFixture(LockFixture)
super(TestCase, self).setUp()
...
This is because addCleanups are put on a LIFO queue that gets run after the
test method exits. (either by completing or raising an exception)
"""
def __init__(self, name, lock_file_prefix=None):
self.mgr = lock(name, lock_file_prefix, True)
def setUp(self):
super(LockFixture, self).setUp()
self.addCleanup(self.mgr.__exit__, None, None, None)
self.mgr.__enter__()

View File

@ -0,0 +1,51 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mock
class PatchObject(fixtures.Fixture):
"""Deal with code around mock."""
def __init__(self, obj, attr, **kwargs):
self.obj = obj
self.attr = attr
self.kwargs = kwargs
def setUp(self):
super(PatchObject, self).setUp()
_p = mock.patch.object(self.obj, self.attr, **self.kwargs)
self.mock = _p.start()
self.addCleanup(_p.stop)
class Patch(fixtures.Fixture):
"""Deal with code around mock.patch."""
def __init__(self, obj, **kwargs):
self.obj = obj
self.kwargs = kwargs
def setUp(self):
super(Patch, self).setUp()
_p = mock.patch(self.obj, **self.kwargs)
self.mock = _p.start()
self.addCleanup(_p.stop)

View File

@ -0,0 +1,34 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import mox
class MoxStubout(fixtures.Fixture):
"""Deal with code around mox and stubout as a fixture."""
def setUp(self):
super(MoxStubout, self).setUp()
# emulate some of the mox stuff, we can't use the metaclass
# because it screws with our generators
self.mox = mox.Mox()
self.stubs = self.mox.stubs
self.addCleanup(self.mox.UnsetStubs)
self.addCleanup(self.mox.VerifyAll)

View File

@ -0,0 +1,305 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
import errno
import functools
import os
import shutil
import subprocess
import sys
import tempfile
import threading
import time
import weakref
from oslo.config import cfg
from designate.openstack.common import fileutils
from designate.openstack.common.gettextutils import _ # noqa
from designate.openstack.common import local
from designate.openstack.common import log as logging
LOG = logging.getLogger(__name__)
util_opts = [
cfg.BoolOpt('disable_process_locking', default=False,
help='Whether to disable inter-process locks'),
cfg.StrOpt('lock_path',
default=os.environ.get("DESIGNATE_LOCK_PATH"),
help=('Directory to use for lock files.'))
]
CONF = cfg.CONF
CONF.register_opts(util_opts)
def set_defaults(lock_path):
cfg.set_defaults(util_opts, lock_path=lock_path)
class _InterProcessLock(object):
"""Lock implementation which allows multiple locks, working around
issues like bugs.debian.org/cgi-bin/bugreport.cgi?bug=632857 and does
not require any cleanup. Since the lock is always held on a file
descriptor rather than outside of the process, the lock gets dropped
automatically if the process crashes, even if __exit__ is not executed.
There are no guarantees regarding usage by multiple green threads in a
single process here. This lock works only between processes. Exclusive
access between local threads should be achieved using the semaphores
in the @synchronized decorator.
Note these locks are released when the descriptor is closed, so it's not
safe to close the file descriptor while another green thread holds the
lock. Just opening and closing the lock file can break synchronisation,
so lock files must be accessed only using this abstraction.
"""
def __init__(self, name):
self.lockfile = None
self.fname = name
def __enter__(self):
self.lockfile = open(self.fname, 'w')
while True:
try:
# Using non-blocking locks since green threads are not
# patched to deal with blocking locking calls.
# Also upon reading the MSDN docs for locking(), it seems
# to have a laughable 10 attempts "blocking" mechanism.
self.trylock()
return self
except IOError as e:
if e.errno in (errno.EACCES, errno.EAGAIN):
# external locks synchronise things like iptables
# updates - give it some time to prevent busy spinning
time.sleep(0.01)
else:
raise
def __exit__(self, exc_type, exc_val, exc_tb):
try:
self.unlock()
self.lockfile.close()
except IOError:
LOG.exception(_("Could not release the acquired lock `%s`"),
self.fname)
def trylock(self):
raise NotImplementedError()
def unlock(self):
raise NotImplementedError()
class _WindowsLock(_InterProcessLock):
def trylock(self):
msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_NBLCK, 1)
def unlock(self):
msvcrt.locking(self.lockfile.fileno(), msvcrt.LK_UNLCK, 1)
class _PosixLock(_InterProcessLock):
def trylock(self):
fcntl.lockf(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
def unlock(self):
fcntl.lockf(self.lockfile, fcntl.LOCK_UN)
if os.name == 'nt':
import msvcrt
InterProcessLock = _WindowsLock
else:
import fcntl
InterProcessLock = _PosixLock
_semaphores = weakref.WeakValueDictionary()
_semaphores_lock = threading.Lock()
@contextlib.contextmanager
def lock(name, lock_file_prefix=None, external=False, lock_path=None):
"""Context based lock
This function yields a `threading.Semaphore` instance (if we don't use
eventlet.monkey_patch(), else `semaphore.Semaphore`) unless external is
True, in which case, it'll yield an InterProcessLock instance.
:param lock_file_prefix: The lock_file_prefix argument is used to provide
lock files on disk with a meaningful prefix.
:param external: The external keyword argument denotes whether this lock
should work across multiple processes. This means that if two different
workers both run a a method decorated with @synchronized('mylock',
external=True), only one of them will execute at a time.
:param lock_path: The lock_path keyword argument is used to specify a
special location for external lock files to live. If nothing is set, then
CONF.lock_path is used as a default.
"""
with _semaphores_lock:
try:
sem = _semaphores[name]
except KeyError:
sem = threading.Semaphore()
_semaphores[name] = sem
with sem:
LOG.debug(_('Got semaphore "%(lock)s"'), {'lock': name})
# NOTE(mikal): I know this looks odd
if not hasattr(local.strong_store, 'locks_held'):
local.strong_store.locks_held = []
local.strong_store.locks_held.append(name)
try:
if external and not CONF.disable_process_locking:
LOG.debug(_('Attempting to grab file lock "%(lock)s"'),
{'lock': name})
# We need a copy of lock_path because it is non-local
local_lock_path = lock_path or CONF.lock_path
if not local_lock_path:
raise cfg.RequiredOptError('lock_path')
if not os.path.exists(local_lock_path):
fileutils.ensure_tree(local_lock_path)
LOG.info(_('Created lock path: %s'), local_lock_path)
def add_prefix(name, prefix):
if not prefix:
return name
sep = '' if prefix.endswith('-') else '-'
return '%s%s%s' % (prefix, sep, name)
# NOTE(mikal): the lock name cannot contain directory
# separators
lock_file_name = add_prefix(name.replace(os.sep, '_'),
lock_file_prefix)
lock_file_path = os.path.join(local_lock_path, lock_file_name)
try:
lock = InterProcessLock(lock_file_path)
with lock as lock:
LOG.debug(_('Got file lock "%(lock)s" at %(path)s'),
{'lock': name, 'path': lock_file_path})
yield lock
finally:
LOG.debug(_('Released file lock "%(lock)s" at %(path)s'),
{'lock': name, 'path': lock_file_path})
else:
yield sem
finally:
local.strong_store.locks_held.remove(name)
def synchronized(name, lock_file_prefix=None, external=False, lock_path=None):
"""Synchronization decorator.
Decorating a method like so::
@synchronized('mylock')
def foo(self, *args):
...
ensures that only one thread will execute the foo method at a time.
Different methods can share the same lock::
@synchronized('mylock')
def foo(self, *args):
...
@synchronized('mylock')
def bar(self, *args):
...
This way only one of either foo or bar can be executing at a time.
"""
def wrap(f):
@functools.wraps(f)
def inner(*args, **kwargs):
try:
with lock(name, lock_file_prefix, external, lock_path):
LOG.debug(_('Got semaphore / lock "%(function)s"'),
{'function': f.__name__})
return f(*args, **kwargs)
finally:
LOG.debug(_('Semaphore / lock released "%(function)s"'),
{'function': f.__name__})
return inner
return wrap
def synchronized_with_prefix(lock_file_prefix):
"""Partial object generator for the synchronization decorator.
Redefine @synchronized in each project like so::
(in nova/utils.py)
from nova.openstack.common import lockutils
synchronized = lockutils.synchronized_with_prefix('nova-')
(in nova/foo.py)
from nova import utils
@utils.synchronized('mylock')
def bar(self, *args):
...
The lock_file_prefix argument is used to provide lock files on disk with a
meaningful prefix.
"""
return functools.partial(synchronized, lock_file_prefix=lock_file_prefix)
def main(argv):
"""Create a dir for locks and pass it to command from arguments
If you run this:
python -m openstack.common.lockutils python setup.py testr <etc>
a temporary directory will be created for all your locks and passed to all
your tests in an environment variable. The temporary dir will be deleted
afterwards and the return value will be preserved.
"""
lock_dir = tempfile.mkdtemp()
os.environ["DESIGNATE_LOCK_PATH"] = lock_dir
try:
ret_val = subprocess.call(argv[1:])
finally:
shutil.rmtree(lock_dir, ignore_errors=True)
return ret_val
if __name__ == '__main__':
sys.exit(main(sys.argv))

View File

@ -0,0 +1,53 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Common utilities used in testing"""
import os
import fixtures
import testtools
_TRUE_VALUES = ('True', 'true', '1', 'yes')
class BaseTestCase(testtools.TestCase):
def setUp(self):
super(BaseTestCase, self).setUp()
self._set_timeout()
self._fake_output()
self.useFixture(fixtures.FakeLogger('designate.openstack.common'))
self.useFixture(fixtures.NestedTempfile())
self.useFixture(fixtures.TempHomeDir())
def _set_timeout(self):
test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
try:
test_timeout = int(test_timeout)
except ValueError:
# If timeout value is invalid do not set a timeout.
test_timeout = 0
if test_timeout > 0:
self.useFixture(fixtures.Timeout(test_timeout, gentle=True))
def _fake_output(self):
if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES:
stdout = self.useFixture(fixtures.StringStream('stdout')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))

View File

@ -14,14 +14,16 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import copy import copy
import unittest2 import fixtures
import mox import functools
import nose
import os import os
from testtools import testcase
from oslo.config import cfg from oslo.config import cfg
from designate.openstack.common import log as logging from designate.openstack.common import log as logging
from designate.openstack.common.notifier import test_notifier from designate.openstack.common.notifier import test_notifier
from designate.openstack.common.fixture import config
from designate.openstack.common import policy from designate.openstack.common import policy
from designate.openstack.common import test
from designate.context import DesignateContext from designate.context import DesignateContext
from designate import storage from designate import storage
from designate import exceptions from designate import exceptions
@ -42,7 +44,18 @@ cfg.CONF.import_opt('database_connection', 'designate.storage.impl_sqlalchemy',
group='storage:sqlalchemy') group='storage:sqlalchemy')
class TestCase(unittest2.TestCase): class NotifierFixture(fixtures.Fixture):
def tearDown(self):
self.clear()
def get(self):
return test_notifier.NOTIFICATIONS
def clear(self):
test_notifier.NOTIFICATIONS = []
class TestCase(test.BaseTestCase):
quota_fixtures = [{ quota_fixtures = [{
'tenant_id': '12345', 'tenant_id': '12345',
'resource': 'domains', 'resource': 'domains',
@ -90,7 +103,7 @@ class TestCase(unittest2.TestCase):
def setUp(self): def setUp(self):
super(TestCase, self).setUp() super(TestCase, self).setUp()
self.mox = mox.Mox() self.CONF = self.useFixture(config.Config(cfg.CONF)).conf
self.config( self.config(
notification_driver=[ notification_driver=[
@ -120,6 +133,11 @@ class TestCase(unittest2.TestCase):
group='storage:sqlalchemy' group='storage:sqlalchemy'
) )
self.CONF([], project='designate')
self.notifications = NotifierFixture()
self.useFixture(self.notifications)
storage.setup_schema() storage.setup_schema()
self.admin_context = self.get_admin_context() self.admin_context = self.get_admin_context()
@ -128,13 +146,8 @@ class TestCase(unittest2.TestCase):
self.reset_notifications() self.reset_notifications()
policy.reset() policy.reset()
storage.teardown_schema() storage.teardown_schema()
cfg.CONF.reset()
self.mox.UnsetStubs()
super(TestCase, self).tearDown() super(TestCase, self).tearDown()
def skip(self, message=None):
raise nose.SkipTest(message)
# Config Methods # Config Methods
def config(self, **kwargs): def config(self, **kwargs):
group = kwargs.pop('group', None) group = kwargs.pop('group', None)
@ -156,10 +169,10 @@ class TestCase(unittest2.TestCase):
# Other Utility Methods # Other Utility Methods
def get_notifications(self): def get_notifications(self):
return test_notifier.NOTIFICATIONS return self.notifications.get()
def reset_notifications(self): def reset_notifications(self):
test_notifier.NOTIFICATIONS = [] self.notifications.clear()
# Service Methods # Service Methods
def get_agent_service(self): def get_agent_service(self):
@ -264,3 +277,27 @@ class TestCase(unittest2.TestCase):
values=kwargs) values=kwargs)
return self.central_service.create_record(context, domain['id'], return self.central_service.create_record(context, domain['id'],
values=values) values=values)
def _skip_decorator(func):
@functools.wraps(func)
def skip_if_not_implemented(*args, **kwargs):
try:
return func(*args, **kwargs)
except NotImplementedError as e:
raise testcase.TestSkipped(str(e))
except Exception as e:
if 'not implemented' in str(e):
raise testcase.TestSkipped(str(e))
raise
return skip_if_not_implemented
class SkipNotImplementedMeta(type):
def __new__(cls, name, bases, local):
for attr in local:
value = local[attr]
if callable(value) and (
attr.startswith('test_') or attr == 'setUp'):
local[attr] = _skip_decorator(value)
return type.__new__(cls, name, bases, local)

View File

@ -17,4 +17,4 @@ from designate.tests import TestCase
class AgentTestCase(TestCase): class AgentTestCase(TestCase):
__test__ = False pass

View File

@ -17,8 +17,6 @@ from designate.tests.test_agent import AgentTestCase
class AgentServiceTest(AgentTestCase): class AgentServiceTest(AgentTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(AgentServiceTest, self).setUp() super(AgentServiceTest, self).setUp()
self.service = self.get_agent_service() self.service = self.get_agent_service()

View File

@ -17,4 +17,4 @@ from designate.tests import TestCase
class ApiTestCase(TestCase): class ApiTestCase(TestCase):
__test__ = False pass

View File

@ -33,8 +33,6 @@ class FakeRequest(object):
class MaintenanceMiddlewareTest(ApiTestCase): class MaintenanceMiddlewareTest(ApiTestCase):
__test__ = True
def test_process_request_disabled(self): def test_process_request_disabled(self):
self.config(maintenance_mode=False, group='service:api') self.config(maintenance_mode=False, group='service:api')
@ -107,8 +105,6 @@ class MaintenanceMiddlewareTest(ApiTestCase):
class KeystoneContextMiddlewareTest(ApiTestCase): class KeystoneContextMiddlewareTest(ApiTestCase):
__test__ = True
def test_process_request(self): def test_process_request(self):
app = middleware.KeystoneContextMiddleware({}) app = middleware.KeystoneContextMiddleware({})
@ -168,8 +164,6 @@ class KeystoneContextMiddlewareTest(ApiTestCase):
class NoAuthContextMiddlewareTest(ApiTestCase): class NoAuthContextMiddlewareTest(ApiTestCase):
__test__ = True
def test_process_request(self): def test_process_request(self):
app = middleware.NoAuthContextMiddleware({}) app = middleware.NoAuthContextMiddleware({})

View File

@ -17,8 +17,6 @@ from designate.tests.test_api import ApiTestCase
class ApiServiceTest(ApiTestCase): class ApiServiceTest(ApiTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(ApiServiceTest, self).setUp() super(ApiServiceTest, self).setUp()

View File

@ -24,8 +24,6 @@ LOG = logging.getLogger(__name__)
class ApiV1Test(ApiTestCase): class ApiV1Test(ApiTestCase):
__test__ = False
def setUp(self): def setUp(self):
super(ApiV1Test, self).setUp() super(ApiV1Test, self).setUp()

View File

@ -26,8 +26,6 @@ LOG = logging.getLogger(__name__)
class ApiV1DomainsTest(ApiV1Test): class ApiV1DomainsTest(ApiV1Test):
__test__ = True
def test_create_domain(self): def test_create_domain(self):
# Create a server # Create a server
self.create_server() self.create_server()

View File

@ -25,8 +25,6 @@ LOG = logging.getLogger(__name__)
class ApiV1RecordsTest(ApiV1Test): class ApiV1RecordsTest(ApiV1Test):
__test__ = True
def setUp(self): def setUp(self):
super(ApiV1RecordsTest, self).setUp() super(ApiV1RecordsTest, self).setUp()

View File

@ -25,8 +25,6 @@ LOG = logging.getLogger(__name__)
class ApiV1ServersTest(ApiV1Test): class ApiV1ServersTest(ApiV1Test):
__test__ = True
def test_create_server(self): def test_create_server(self):
# Create a server # Create a server
fixture = self.get_server_fixture(0) fixture = self.get_server_fixture(0)

View File

@ -24,8 +24,6 @@ LOG = logging.getLogger(__name__)
class ApiV2TestCase(ApiTestCase): class ApiV2TestCase(ApiTestCase):
__test__ = False
def setUp(self): def setUp(self):
super(ApiV2TestCase, self).setUp() super(ApiV2TestCase, self).setUp()

View File

@ -18,8 +18,6 @@ from designate.tests.test_api.test_v2 import ApiV2TestCase
class ApiV2LimitsTest(ApiV2TestCase): class ApiV2LimitsTest(ApiV2TestCase):
__test__ = True
def test_get_limits(self): def test_get_limits(self):
response = self.client.get('/limits/') response = self.client.get('/limits/')

View File

@ -22,8 +22,6 @@ from designate.tests.test_api.test_v2 import ApiV2TestCase
class ApiV2ZonesTest(ApiV2TestCase): class ApiV2ZonesTest(ApiV2TestCase):
__test__ = True
def setUp(self): def setUp(self):
super(ApiV2ZonesTest, self).setUp() super(ApiV2ZonesTest, self).setUp()

View File

@ -22,8 +22,6 @@ LOG = logging.getLogger(__name__)
class BackendTestCase(TestCase): class BackendTestCase(TestCase):
__test__ = False
def get_backend_driver(self): def get_backend_driver(self):
central_service = self.get_central_service() central_service = self.get_central_service()
return backend.get_backend(cfg.CONF['service:agent'].backend_driver, return backend.get_backend(cfg.CONF['service:agent'].backend_driver,

View File

@ -20,8 +20,6 @@ LOG = logging.getLogger(__name__)
class Bind9BackendDriverTestCase(BackendTestCase): class Bind9BackendDriverTestCase(BackendTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(Bind9BackendDriverTestCase, self).setUp() super(Bind9BackendDriverTestCase, self).setUp()

View File

@ -20,8 +20,6 @@ LOG = logging.getLogger(__name__)
class DnsmasqBackendDriverTestCase(BackendTestCase): class DnsmasqBackendDriverTestCase(BackendTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(DnsmasqBackendDriverTestCase, self).setUp() super(DnsmasqBackendDriverTestCase, self).setUp()

View File

@ -20,8 +20,6 @@ LOG = logging.getLogger(__name__)
class FakeBackendDriverTestCase(BackendTestCase): class FakeBackendDriverTestCase(BackendTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(FakeBackendDriverTestCase, self).setUp() super(FakeBackendDriverTestCase, self).setUp()

View File

@ -20,8 +20,6 @@ LOG = logging.getLogger(__name__)
class MySQLBind9BackendDriverTestCase(BackendTestCase): class MySQLBind9BackendDriverTestCase(BackendTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(MySQLBind9BackendDriverTestCase, self).setUp() super(MySQLBind9BackendDriverTestCase, self).setUp()

View File

@ -20,8 +20,6 @@ LOG = logging.getLogger(__name__)
class PowerDNSBackendDriverTestCase(BackendTestCase): class PowerDNSBackendDriverTestCase(BackendTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(PowerDNSBackendDriverTestCase, self).setUp() super(PowerDNSBackendDriverTestCase, self).setUp()

View File

@ -17,4 +17,4 @@ from designate.tests import TestCase
class CentralTestCase(TestCase): class CentralTestCase(TestCase):
__test__ = False pass

View File

@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import random import random
import testtools
from designate.openstack.common import log as logging from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate.tests.test_central import CentralTestCase from designate.tests.test_central import CentralTestCase
@ -22,8 +23,6 @@ LOG = logging.getLogger(__name__)
class CentralServiceTest(CentralTestCase): class CentralServiceTest(CentralTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(CentralServiceTest, self).setUp() super(CentralServiceTest, self).setUp()
self.central_service = self.get_central_service() self.central_service = self.get_central_service()
@ -42,10 +41,10 @@ class CentralServiceTest(CentralTestCase):
self.central_service._is_valid_domain_name(context, 'valid.org.') self.central_service._is_valid_domain_name(context, 'valid.org.')
with self.assertRaises(exceptions.InvalidDomainName): with testtools.ExpectedException(exceptions.InvalidDomainName):
self.central_service._is_valid_domain_name(context, 'example.org.') self.central_service._is_valid_domain_name(context, 'example.org.')
with self.assertRaises(exceptions.InvalidDomainName): with testtools.ExpectedException(exceptions.InvalidDomainName):
self.central_service._is_valid_domain_name(context, 'example.tld.') self.central_service._is_valid_domain_name(context, 'example.tld.')
def test_is_valid_record_name(self): def test_is_valid_record_name(self):
@ -61,15 +60,15 @@ class CentralServiceTest(CentralTestCase):
'valid.example.org.', 'valid.example.org.',
'A') 'A')
with self.assertRaises(exceptions.InvalidRecordName): with testtools.ExpectedException(exceptions.InvalidRecordName):
self.central_service._is_valid_record_name( self.central_service._is_valid_record_name(
context, domain, 'toolong.example.org.', 'A') context, domain, 'toolong.example.org.', 'A')
with self.assertRaises(exceptions.InvalidRecordLocation): with testtools.ExpectedException(exceptions.InvalidRecordLocation):
self.central_service._is_valid_record_name( self.central_service._is_valid_record_name(
context, domain, 'a.example.COM.', 'A') context, domain, 'a.example.COM.', 'A')
with self.assertRaises(exceptions.InvalidRecordLocation): with testtools.ExpectedException(exceptions.InvalidRecordLocation):
self.central_service._is_valid_record_name( self.central_service._is_valid_record_name(
context, domain, 'example.org.', 'CNAME') context, domain, 'example.org.', 'CNAME')
@ -201,12 +200,15 @@ class CentralServiceTest(CentralTestCase):
self.central_service.delete_server(context, server['id']) self.central_service.delete_server(context, server['id'])
# Fetch the server again, ensuring an exception is raised # Fetch the server again, ensuring an exception is raised
with self.assertRaises(exceptions.ServerNotFound): self.assertRaises(
self.central_service.get_server(context, server['id']) exceptions.ServerNotFound,
self.central_service.get_server,
context, server['id'])
# Try to delete last remaining server - expect exception # Try to delete last remaining server - expect exception
with self.assertRaises(exceptions.LastServerDeleteNotAllowed): self.assertRaises(
self.central_service.delete_server(context, server2['id']) exceptions.LastServerDeleteNotAllowed,
self.central_service.delete_server, context, server2['id'])
# TsigKey Tests # TsigKey Tests
def test_create_tsigkey(self): def test_create_tsigkey(self):
@ -288,7 +290,7 @@ class CentralServiceTest(CentralTestCase):
self.central_service.delete_tsigkey(context, tsigkey['id']) self.central_service.delete_tsigkey(context, tsigkey['id'])
# Fetch the tsigkey again, ensuring an exception is raised # Fetch the tsigkey again, ensuring an exception is raised
with self.assertRaises(exceptions.TsigKeyNotFound): with testtools.ExpectedException(exceptions.TsigKeyNotFound):
self.central_service.get_tsigkey(context, tsigkey['id']) self.central_service.get_tsigkey(context, tsigkey['id'])
# Tenant Tests # Tenant Tests
@ -311,7 +313,7 @@ class CentralServiceTest(CentralTestCase):
# Set the policy to reject the authz # Set the policy to reject the authz
self.policy({'count_tenants': '!'}) self.policy({'count_tenants': '!'})
with self.assertRaises(exceptions.Forbidden): with testtools.ExpectedException(exceptions.Forbidden):
self.central_service.count_tenants(self.get_context()) self.central_service.count_tenants(self.get_context())
# Domain Tests # Domain Tests
@ -360,7 +362,7 @@ class CentralServiceTest(CentralTestCase):
self.create_domain() self.create_domain()
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.create_domain() self.create_domain()
def test_create_subdomain(self): def test_create_subdomain(self):
@ -402,7 +404,7 @@ class CentralServiceTest(CentralTestCase):
values['name'] = 'www.%s' % parent_domain['name'] values['name'] = 'www.%s' % parent_domain['name']
# Attempt to create the subdomain # Attempt to create the subdomain
with self.assertRaises(exceptions.Forbidden): with testtools.ExpectedException(exceptions.Forbidden):
self.central_service.create_domain(context, values=values) self.central_service.create_domain(context, values=values)
def test_create_blacklisted_domain_success(self): def test_create_blacklisted_domain_success(self):
@ -444,7 +446,7 @@ class CentralServiceTest(CentralTestCase):
email='info@blacklisted.com' email='info@blacklisted.com'
) )
with self.assertRaises(exceptions.InvalidDomainName): with testtools.ExpectedException(exceptions.InvalidDomainName):
# Create a domain # Create a domain
self.central_service.create_domain(context, values=values) self.central_service.create_domain(context, values=values)
@ -470,7 +472,7 @@ class CentralServiceTest(CentralTestCase):
email='info@invalid.com' email='info@invalid.com'
) )
with self.assertRaises(exceptions.InvalidTLD): with testtools.ExpectedException(exceptions.InvalidTLD):
# Create an invalid domain # Create an invalid domain
self.central_service.create_domain(context, values=values) self.central_service.create_domain(context, values=values)
@ -561,7 +563,7 @@ class CentralServiceTest(CentralTestCase):
# Retrieve the servers list # Retrieve the servers list
servers = self.central_service.get_domain_servers(context, servers = self.central_service.get_domain_servers(context,
domain['id']) domain['id'])
self.assertGreater(len(servers), 0) self.assertTrue(len(servers) > 0)
def test_find_domain(self): def test_find_domain(self):
context = self.get_admin_context() context = self.get_admin_context()
@ -597,7 +599,7 @@ class CentralServiceTest(CentralTestCase):
expected_domain['id']) expected_domain['id'])
# Ensure the domain was updated correctly # Ensure the domain was updated correctly
self.assertGreater(domain['serial'], expected_domain['serial']) self.assertTrue(domain['serial'] > expected_domain['serial'])
self.assertEqual(domain['email'], 'new@example.com') self.assertEqual(domain['email'], 'new@example.com')
# Ensure we sent exactly 1 notification # Ensure we sent exactly 1 notification
@ -644,7 +646,7 @@ class CentralServiceTest(CentralTestCase):
expected_domain = self.create_domain() expected_domain = self.create_domain()
# Update the domain # Update the domain
with self.assertRaises(exceptions.BadRequest): with testtools.ExpectedException(exceptions.BadRequest):
values = dict(name='renamed-domain.com.') values = dict(name='renamed-domain.com.')
self.central_service.update_domain(context, expected_domain['id'], self.central_service.update_domain(context, expected_domain['id'],
values=values) values=values)
@ -662,7 +664,7 @@ class CentralServiceTest(CentralTestCase):
self.central_service.delete_domain(context, domain['id']) self.central_service.delete_domain(context, domain['id'])
# Fetch the domain again, ensuring an exception is raised # Fetch the domain again, ensuring an exception is raised
with self.assertRaises(exceptions.DomainNotFound): with testtools.ExpectedException(exceptions.DomainNotFound):
self.central_service.get_domain(context, domain['id']) self.central_service.get_domain(context, domain['id'])
# Ensure we sent exactly 1 notification # Ensure we sent exactly 1 notification
@ -696,7 +698,7 @@ class CentralServiceTest(CentralTestCase):
self.central_service.create_domain(context, values=values) self.central_service.create_domain(context, values=values)
# Attempt to delete the parent domain # Attempt to delete the parent domain
with self.assertRaises(exceptions.DomainHasSubdomain): with testtools.ExpectedException(exceptions.DomainHasSubdomain):
self.central_service.delete_domain(context, parent_domain['id']) self.central_service.delete_domain(context, parent_domain['id'])
def test_count_domains(self): def test_count_domains(self):
@ -717,7 +719,7 @@ class CentralServiceTest(CentralTestCase):
# Set the policy to reject the authz # Set the policy to reject the authz
self.policy({'count_domains': '!'}) self.policy({'count_domains': '!'})
with self.assertRaises(exceptions.Forbidden): with testtools.ExpectedException(exceptions.Forbidden):
self.central_service.count_domains(self.get_context()) self.central_service.count_domains(self.get_context())
def test_touch_domain(self): def test_touch_domain(self):
@ -734,7 +736,7 @@ class CentralServiceTest(CentralTestCase):
expected_domain['id']) expected_domain['id'])
# Ensure the serial was incremented # Ensure the serial was incremented
self.assertGreater(domain['serial'], expected_domain['serial']) self.assertTrue(domain['serial'] > expected_domain['serial'])
# Record Tests # Record Tests
def test_create_record(self): def test_create_record(self):
@ -766,7 +768,7 @@ class CentralServiceTest(CentralTestCase):
self.create_record(domain) self.create_record(domain)
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.create_record(domain) self.create_record(domain)
def test_create_record_without_incrementing_serial(self): def test_create_record_without_incrementing_serial(self):
@ -806,7 +808,7 @@ class CentralServiceTest(CentralTestCase):
) )
# Attempt to create a CNAME record at the apex # Attempt to create a CNAME record at the apex
with self.assertRaises(exceptions.InvalidRecordLocation): with testtools.ExpectedException(exceptions.InvalidRecordLocation):
self.central_service.create_record(context, domain['id'], self.central_service.create_record(context, domain['id'],
values=values) values=values)
@ -874,7 +876,7 @@ class CentralServiceTest(CentralTestCase):
values=values) values=values)
# Attempt to create a CNAME record alongside an A record # Attempt to create a CNAME record alongside an A record
with self.assertRaises(exceptions.InvalidRecordLocation): with testtools.ExpectedException(exceptions.InvalidRecordLocation):
values = dict( values = dict(
name='www.%s' % domain['name'], name='www.%s' % domain['name'],
type='CNAME', type='CNAME',
@ -898,7 +900,7 @@ class CentralServiceTest(CentralTestCase):
values=values) values=values)
# Attempt to create a CNAME record alongside an A record # Attempt to create a CNAME record alongside an A record
with self.assertRaises(exceptions.InvalidRecordLocation): with testtools.ExpectedException(exceptions.InvalidRecordLocation):
values = dict( values = dict(
name='www.%s' % domain['name'], name='www.%s' % domain['name'],
type='A', type='A',
@ -922,7 +924,7 @@ class CentralServiceTest(CentralTestCase):
values=values) values=values)
# Attempt to create a second PTR with the same name. # Attempt to create a second PTR with the same name.
with self.assertRaises(exceptions.DuplicateRecord): with testtools.ExpectedException(exceptions.DuplicateRecord):
values = dict( values = dict(
name='1.%s' % domain['name'], name='1.%s' % domain['name'],
type='PTR', type='PTR',
@ -998,7 +1000,7 @@ class CentralServiceTest(CentralTestCase):
expected_record = self.create_record(domain, name=record_name) expected_record = self.create_record(domain, name=record_name)
# Ensure we get a 404 if we use the incorrect domain_id # Ensure we get a 404 if we use the incorrect domain_id
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
self.central_service.get_record(context, other_domain['id'], self.central_service.get_record(context, other_domain['id'],
expected_record['id']) expected_record['id'])
@ -1063,7 +1065,7 @@ class CentralServiceTest(CentralTestCase):
values = dict(data='127.0.0.2') values = dict(data='127.0.0.2')
# Ensure we get a 404 if we use the incorrect domain_id # Ensure we get a 404 if we use the incorrect domain_id
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
self.central_service.update_record(context, other_domain['id'], self.central_service.update_record(context, other_domain['id'],
expected_record['id'], expected_record['id'],
values=values) values=values)
@ -1091,7 +1093,7 @@ class CentralServiceTest(CentralTestCase):
values=values) values=values)
# Attempt to create a second PTR with the same name. # Attempt to create a second PTR with the same name.
with self.assertRaises(exceptions.DuplicateRecord): with testtools.ExpectedException(exceptions.DuplicateRecord):
values = dict( values = dict(
name='1.%s' % domain['name'] name='1.%s' % domain['name']
) )
@ -1156,7 +1158,7 @@ class CentralServiceTest(CentralTestCase):
self.central_service.delete_record(context, domain['id'], record['id']) self.central_service.delete_record(context, domain['id'], record['id'])
# Fetch the record again, ensuring an exception is raised # Fetch the record again, ensuring an exception is raised
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
self.central_service.get_record(context, domain['id'], self.central_service.get_record(context, domain['id'],
record['id']) record['id'])
@ -1175,7 +1177,7 @@ class CentralServiceTest(CentralTestCase):
increment_serial=False) increment_serial=False)
# Fetch the record again, ensuring an exception is raised # Fetch the record again, ensuring an exception is raised
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
self.central_service.get_record(context, domain['id'], self.central_service.get_record(context, domain['id'],
record['id']) record['id'])
@ -1192,7 +1194,7 @@ class CentralServiceTest(CentralTestCase):
record = self.create_record(domain) record = self.create_record(domain)
# Ensure we get a 404 if we use the incorrect domain_id # Ensure we get a 404 if we use the incorrect domain_id
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
self.central_service.delete_record(context, other_domain['id'], self.central_service.delete_record(context, other_domain['id'],
record['id']) record['id'])
@ -1215,5 +1217,5 @@ class CentralServiceTest(CentralTestCase):
# Set the policy to reject the authz # Set the policy to reject the authz
self.policy({'count_records': '!'}) self.policy({'count_records': '!'})
with self.assertRaises(exceptions.Forbidden): with testtools.ExpectedException(exceptions.Forbidden):
self.central_service.count_records(self.get_context()) self.central_service.count_records(self.get_context())

View File

@ -15,16 +15,19 @@
# under the License. # under the License.
import json import json
import os import os
import six
import testtools
from designate.notification_handler.base import Handler from designate.notification_handler.base import Handler
from designate.tests import TestCase from designate.tests import TestCase
from designate.tests import SkipNotImplementedMeta
FIXTURES_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), FIXTURES_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..', '..',
'sample_notifications')) 'sample_notifications'))
@six.add_metaclass(SkipNotImplementedMeta)
class NotificationHandlerTestCase(TestCase): class NotificationHandlerTestCase(TestCase):
__test__ = False
__plugin_base__ = Handler __plugin_base__ = Handler
def setUp(self): def setUp(self):
@ -47,9 +50,11 @@ class NotificationHandlerTestCase(TestCase):
return json.load(fh) return json.load(fh)
def test_invalid_event_type(self): def test_invalid_event_type(self):
if not hasattr(self, 'plugin'):
raise NotImplementedError
event_type = 'invalid' event_type = 'invalid'
self.assertNotIn(event_type, self.plugin.get_event_types()) self.assertNotIn(event_type, self.plugin.get_event_types())
with self.assertRaises(ValueError): with testtools.ExpectedException(ValueError):
self.plugin.process_notification(event_type, 'payload') self.plugin.process_notification(event_type, 'payload')

View File

@ -22,8 +22,6 @@ LOG = logging.getLogger(__name__)
class NovaFixedHandlerTest(NotificationHandlerTestCase): class NovaFixedHandlerTest(NotificationHandlerTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(NovaFixedHandlerTest, self).setUp() super(NovaFixedHandlerTest, self).setUp()
@ -71,7 +69,7 @@ class NovaFixedHandlerTest(NotificationHandlerTestCase):
records = self.central_service.find_records(self.admin_context, records = self.central_service.find_records(self.admin_context,
self.domain_id) self.domain_id)
self.assertGreaterEqual(len(records), 1) self.assertTrue(len(records) >= 1)
self.plugin.process_notification(event_type, fixture['payload']) self.plugin.process_notification(event_type, fixture['payload'])

View File

@ -22,8 +22,6 @@ LOG = logging.getLogger(__name__)
class QuantumFloatingHandlerTest(NotificationHandlerTestCase): class QuantumFloatingHandlerTest(NotificationHandlerTestCase):
__test__ = True
def setUp(self): def setUp(self):
super(QuantumFloatingHandlerTest, self).setUp() super(QuantumFloatingHandlerTest, self).setUp()
@ -71,7 +69,7 @@ class QuantumFloatingHandlerTest(NotificationHandlerTestCase):
records = self.central_service.find_records(self.admin_context, records = self.central_service.find_records(self.admin_context,
self.domain_id) self.domain_id)
self.assertGreaterEqual(len(records), 1) self.assertTrue(len(records) >= 1)
self.plugin.process_notification(event_type, fixture['payload']) self.plugin.process_notification(event_type, fixture['payload'])

View File

@ -13,6 +13,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import testtools
from oslo.config import cfg from oslo.config import cfg
from designate.openstack.common import log as logging from designate.openstack.common import log as logging
from designate.tests import TestCase from designate.tests import TestCase
@ -23,8 +24,6 @@ LOG = logging.getLogger(__name__)
class QuotaTestCase(TestCase): class QuotaTestCase(TestCase):
__test__ = False
def setUp(self): def setUp(self):
super(QuotaTestCase, self).setUp() super(QuotaTestCase, self).setUp()
self.quota = quota.get_quota() self.quota = quota.get_quota()
@ -43,10 +42,10 @@ class QuotaTestCase(TestCase):
def test_limit_check_unknown(self): def test_limit_check_unknown(self):
context = self.get_admin_context() context = self.get_admin_context()
with self.assertRaises(exceptions.QuotaResourceUnknown): with testtools.ExpectedException(exceptions.QuotaResourceUnknown):
self.quota.limit_check(context, 'tenant_id', unknown=0) self.quota.limit_check(context, 'tenant_id', unknown=0)
with self.assertRaises(exceptions.QuotaResourceUnknown): with testtools.ExpectedException(exceptions.QuotaResourceUnknown):
self.quota.limit_check(context, 'tenant_id', unknown=0, domains=0) self.quota.limit_check(context, 'tenant_id', unknown=0, domains=0)
def test_limit_check_under(self): def test_limit_check_under(self):
@ -67,11 +66,11 @@ class QuotaTestCase(TestCase):
def test_limit_check_at(self): def test_limit_check_at(self):
context = self.get_admin_context() context = self.get_admin_context()
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', self.quota.limit_check(context, 'tenant_id',
domains=cfg.CONF.quota_domains) domains=cfg.CONF.quota_domains)
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.quota.limit_check( self.quota.limit_check(
context, context,
'tenant_id', 'tenant_id',
@ -80,20 +79,20 @@ class QuotaTestCase(TestCase):
def test_limit_check_over(self): def test_limit_check_over(self):
context = self.get_admin_context() context = self.get_admin_context()
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domains=99999) self.quota.limit_check(context, 'tenant_id', domains=99999)
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domain_records=99999) self.quota.limit_check(context, 'tenant_id', domain_records=99999)
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domains=99999, self.quota.limit_check(context, 'tenant_id', domains=99999,
domain_records=99999) domain_records=99999)
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domains=99999, self.quota.limit_check(context, 'tenant_id', domains=99999,
domain_records=0) domain_records=0)
with self.assertRaises(exceptions.OverQuota): with testtools.ExpectedException(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domains=0, self.quota.limit_check(context, 'tenant_id', domains=0,
domain_records=99999) domain_records=99999)

View File

@ -20,8 +20,6 @@ LOG = logging.getLogger(__name__)
class NoopQuotaTest(QuotaTestCase): class NoopQuotaTest(QuotaTestCase):
__test__ = True
def setUp(self): def setUp(self):
self.config(quota_driver='noop') self.config(quota_driver='noop')
super(NoopQuotaTest, self).setUp() super(NoopQuotaTest, self).setUp()

View File

@ -20,8 +20,6 @@ LOG = logging.getLogger(__name__)
class StorageQuotaTest(QuotaTestCase): class StorageQuotaTest(QuotaTestCase):
__test__ = True
def setUp(self): def setUp(self):
self.config(quota_driver='storage') self.config(quota_driver='storage')
super(StorageQuotaTest, self).setUp() super(StorageQuotaTest, self).setUp()
@ -30,7 +28,7 @@ class StorageQuotaTest(QuotaTestCase):
quota = self.quota.set_quota(self.admin_context, 'tenant_id', quota = self.quota.set_quota(self.admin_context, 'tenant_id',
'domains', 1500) 'domains', 1500)
self.assertEquals(quota, {'domains': 1500}) self.assertEqual(quota, {'domains': 1500})
# Drop into the storage layer directly to ensure the quota was created # Drop into the storage layer directly to ensure the quota was created
# sucessfully. # sucessfully.
@ -42,9 +40,9 @@ class StorageQuotaTest(QuotaTestCase):
quota = self.quota.storage_api.find_quota(self.admin_context, quota = self.quota.storage_api.find_quota(self.admin_context,
criterion) criterion)
self.assertEquals(quota['tenant_id'], 'tenant_id') self.assertEqual(quota['tenant_id'], 'tenant_id')
self.assertEquals(quota['resource'], 'domains') self.assertEqual(quota['resource'], 'domains')
self.assertEquals(quota['hard_limit'], 1500) self.assertEqual(quota['hard_limit'], 1500)
def test_set_quota_update(self): def test_set_quota_update(self):
# First up, Create the quota # First up, Create the quota
@ -63,9 +61,9 @@ class StorageQuotaTest(QuotaTestCase):
quota = self.quota.storage_api.find_quota(self.admin_context, quota = self.quota.storage_api.find_quota(self.admin_context,
criterion) criterion)
self.assertEquals(quota['tenant_id'], 'tenant_id') self.assertEqual(quota['tenant_id'], 'tenant_id')
self.assertEquals(quota['resource'], 'domains') self.assertEqual(quota['resource'], 'domains')
self.assertEquals(quota['hard_limit'], 1234) self.assertEqual(quota['hard_limit'], 1234)
def test_reset_quotas(self): def test_reset_quotas(self):
# First up, Create a domains quota # First up, Create a domains quota
@ -87,4 +85,4 @@ class StorageQuotaTest(QuotaTestCase):
quotas = self.quota.storage_api.find_quotas(self.admin_context, quotas = self.quota.storage_api.find_quotas(self.admin_context,
criterion) criterion)
self.assertEquals(0, len(quotas)) self.assertEqual(0, len(quotas))

View File

@ -13,6 +13,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import testtools
from designate.openstack.common import log as logging from designate.openstack.common import log as logging
from designate import exceptions from designate import exceptions
from designate import schema from designate import schema
@ -22,8 +23,6 @@ LOG = logging.getLogger(__name__)
class SchemasV2Test(TestCase): class SchemasV2Test(TestCase):
__test__ = True
def test_recordset(self): def test_recordset(self):
validator = schema.Schema('v2', 'recordset') validator = schema.Schema('v2', 'recordset')
@ -54,7 +53,7 @@ class SchemasV2Test(TestCase):
} }
}) })
with self.assertRaises(exceptions.InvalidObject): with testtools.ExpectedException(exceptions.InvalidObject):
# Fail Expected - Empty Records Array # Fail Expected - Empty Records Array
validator.validate({ validator.validate({
'recordset': { 'recordset': {
@ -66,7 +65,7 @@ class SchemasV2Test(TestCase):
} }
}) })
with self.assertRaises(exceptions.InvalidObject): with testtools.ExpectedException(exceptions.InvalidObject):
# Fail Expected - No Records # Fail Expected - No Records
validator.validate({ validator.validate({
'recordset': { 'recordset': {
@ -77,7 +76,7 @@ class SchemasV2Test(TestCase):
} }
}) })
with self.assertRaises(exceptions.InvalidObject): with testtools.ExpectedException(exceptions.InvalidObject):
# Fail Expected - MX records in an A RRset # Fail Expected - MX records in an A RRset
validator.validate({ validator.validate({
'recordset': { 'recordset': {
@ -92,7 +91,7 @@ class SchemasV2Test(TestCase):
} }
}) })
with self.assertRaises(exceptions.InvalidObject): with testtools.ExpectedException(exceptions.InvalidObject):
# Fail Expected - A records in an MX RRset # Fail Expected - A records in an MX RRset
validator.validate({ validator.validate({
'recordset': { 'recordset': {
@ -107,7 +106,7 @@ class SchemasV2Test(TestCase):
} }
}) })
with self.assertRaises(exceptions.InvalidObject): with testtools.ExpectedException(exceptions.InvalidObject):
# Fail Expected - AAAA records in an A RRset # Fail Expected - AAAA records in an A RRset
validator.validate({ validator.validate({
'recordset': { 'recordset': {

View File

@ -13,21 +13,15 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import testtools
from designate.openstack.common import log as logging from designate.openstack.common import log as logging
from designate.tests import TestCase
from designate import storage
from designate import exceptions from designate import exceptions
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class StorageTestCase(TestCase): class StorageTestCase(object):
__test__ = False
def setUp(self):
super(StorageTestCase, self).setUp()
self.storage = storage.get_storage()
def create_quota(self, fixture=0, values={}): def create_quota(self, fixture=0, values={}):
fixture = self.get_quota_fixture(fixture, values) fixture = self.get_quota_fixture(fixture, values)
return fixture, self.storage.create_quota(self.admin_context, fixture) return fixture, self.storage.create_quota(self.admin_context, fixture)
@ -70,7 +64,7 @@ class StorageTestCase(TestCase):
# Create the initial quota # Create the initial quota
self.create_quota() self.create_quota()
with self.assertRaises(exceptions.DuplicateQuota): with testtools.ExpectedException(exceptions.DuplicateQuota):
self.create_quota() self.create_quota()
def test_find_quotas(self): def test_find_quotas(self):
@ -137,7 +131,7 @@ class StorageTestCase(TestCase):
self.assertEqual(actual['hard_limit'], expected['hard_limit']) self.assertEqual(actual['hard_limit'], expected['hard_limit'])
def test_get_quota_missing(self): def test_get_quota_missing(self):
with self.assertRaises(exceptions.QuotaNotFound): with testtools.ExpectedException(exceptions.QuotaNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.get_quota(self.admin_context, uuid) self.storage.get_quota(self.admin_context, uuid)
@ -174,7 +168,7 @@ class StorageTestCase(TestCase):
tenant_id=expected['tenant_id'] + "NOT FOUND" tenant_id=expected['tenant_id'] + "NOT FOUND"
) )
with self.assertRaises(exceptions.QuotaNotFound): with testtools.ExpectedException(exceptions.QuotaNotFound):
self.storage.find_quota(self.admin_context, criterion) self.storage.find_quota(self.admin_context, criterion)
def test_update_quota(self): def test_update_quota(self):
@ -195,12 +189,12 @@ class StorageTestCase(TestCase):
values = self.quota_fixtures[0] values = self.quota_fixtures[0]
with self.assertRaises(exceptions.DuplicateQuota): with testtools.ExpectedException(exceptions.DuplicateQuota):
self.storage.update_quota(self.admin_context, quota['id'], self.storage.update_quota(self.admin_context, quota['id'],
values) values)
def test_update_quota_missing(self): def test_update_quota_missing(self):
with self.assertRaises(exceptions.QuotaNotFound): with testtools.ExpectedException(exceptions.QuotaNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.update_quota(self.admin_context, uuid, {}) self.storage.update_quota(self.admin_context, uuid, {})
@ -209,11 +203,11 @@ class StorageTestCase(TestCase):
self.storage.delete_quota(self.admin_context, quota['id']) self.storage.delete_quota(self.admin_context, quota['id'])
with self.assertRaises(exceptions.QuotaNotFound): with testtools.ExpectedException(exceptions.QuotaNotFound):
self.storage.get_quota(self.admin_context, quota['id']) self.storage.get_quota(self.admin_context, quota['id'])
def test_delete_quota_missing(self): def test_delete_quota_missing(self):
with self.assertRaises(exceptions.QuotaNotFound): with testtools.ExpectedException(exceptions.QuotaNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.delete_quota(self.admin_context, uuid) self.storage.delete_quota(self.admin_context, uuid)
@ -235,7 +229,7 @@ class StorageTestCase(TestCase):
# Create the Initial Server # Create the Initial Server
self.create_server() self.create_server()
with self.assertRaises(exceptions.DuplicateServer): with testtools.ExpectedException(exceptions.DuplicateServer):
self.create_server() self.create_server()
def test_find_servers(self): def test_find_servers(self):
@ -290,7 +284,7 @@ class StorageTestCase(TestCase):
self.assertEqual(str(actual['name']), str(expected['name'])) self.assertEqual(str(actual['name']), str(expected['name']))
def test_get_server_missing(self): def test_get_server_missing(self):
with self.assertRaises(exceptions.ServerNotFound): with testtools.ExpectedException(exceptions.ServerNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.get_server(self.admin_context, uuid) self.storage.get_server(self.admin_context, uuid)
@ -310,12 +304,12 @@ class StorageTestCase(TestCase):
values = self.server_fixtures[0] values = self.server_fixtures[0]
with self.assertRaises(exceptions.DuplicateServer): with testtools.ExpectedException(exceptions.DuplicateServer):
self.storage.update_server(self.admin_context, server['id'], self.storage.update_server(self.admin_context, server['id'],
values) values)
def test_update_server_missing(self): def test_update_server_missing(self):
with self.assertRaises(exceptions.ServerNotFound): with testtools.ExpectedException(exceptions.ServerNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.update_server(self.admin_context, uuid, {}) self.storage.update_server(self.admin_context, uuid, {})
@ -324,11 +318,11 @@ class StorageTestCase(TestCase):
self.storage.delete_server(self.admin_context, server['id']) self.storage.delete_server(self.admin_context, server['id'])
with self.assertRaises(exceptions.ServerNotFound): with testtools.ExpectedException(exceptions.ServerNotFound):
self.storage.get_server(self.admin_context, server['id']) self.storage.get_server(self.admin_context, server['id'])
def test_delete_server_missing(self): def test_delete_server_missing(self):
with self.assertRaises(exceptions.ServerNotFound): with testtools.ExpectedException(exceptions.ServerNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.delete_server(self.admin_context, uuid) self.storage.delete_server(self.admin_context, uuid)
@ -353,7 +347,7 @@ class StorageTestCase(TestCase):
values = self.get_tsigkey_fixture(1) values = self.get_tsigkey_fixture(1)
values['name'] = tsigkey_one['name'] values['name'] = tsigkey_one['name']
with self.assertRaises(exceptions.DuplicateTsigKey): with testtools.ExpectedException(exceptions.DuplicateTsigKey):
self.create_tsigkey(values=values) self.create_tsigkey(values=values)
def test_find_tsigkeys(self): def test_find_tsigkeys(self):
@ -415,7 +409,7 @@ class StorageTestCase(TestCase):
self.assertEqual(actual['secret'], expected['secret']) self.assertEqual(actual['secret'], expected['secret'])
def test_get_tsigkey_missing(self): def test_get_tsigkey_missing(self):
with self.assertRaises(exceptions.TsigKeyNotFound): with testtools.ExpectedException(exceptions.TsigKeyNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.get_tsigkey(self.admin_context, uuid) self.storage.get_tsigkey(self.admin_context, uuid)
@ -438,12 +432,12 @@ class StorageTestCase(TestCase):
values = self.tsigkey_fixtures[0] values = self.tsigkey_fixtures[0]
with self.assertRaises(exceptions.DuplicateTsigKey): with testtools.ExpectedException(exceptions.DuplicateTsigKey):
self.storage.update_tsigkey(self.admin_context, tsigkey['id'], self.storage.update_tsigkey(self.admin_context, tsigkey['id'],
values) values)
def test_update_tsigkey_missing(self): def test_update_tsigkey_missing(self):
with self.assertRaises(exceptions.TsigKeyNotFound): with testtools.ExpectedException(exceptions.TsigKeyNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.update_tsigkey(self.admin_context, uuid, {}) self.storage.update_tsigkey(self.admin_context, uuid, {})
@ -452,11 +446,11 @@ class StorageTestCase(TestCase):
self.storage.delete_tsigkey(self.admin_context, tsigkey['id']) self.storage.delete_tsigkey(self.admin_context, tsigkey['id'])
with self.assertRaises(exceptions.TsigKeyNotFound): with testtools.ExpectedException(exceptions.TsigKeyNotFound):
self.storage.get_tsigkey(self.admin_context, tsigkey['id']) self.storage.get_tsigkey(self.admin_context, tsigkey['id'])
def test_delete_tsigkey_missing(self): def test_delete_tsigkey_missing(self):
with self.assertRaises(exceptions.TsigKeyNotFound): with testtools.ExpectedException(exceptions.TsigKeyNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.delete_tsigkey(self.admin_context, uuid) self.storage.delete_tsigkey(self.admin_context, uuid)
@ -481,7 +475,7 @@ class StorageTestCase(TestCase):
'domain_count': 1 'domain_count': 1
}] }]
self.assertEquals(result, expected) self.assertEqual(result, expected)
def test_get_tenant(self): def test_get_tenant(self):
# create 2 domains in a tenant # create 2 domains in a tenant
@ -494,10 +488,10 @@ class StorageTestCase(TestCase):
result = self.storage.get_tenant(self.admin_context, 1) result = self.storage.get_tenant(self.admin_context, 1)
self.assertEquals(result['id'], 1) self.assertEqual(result['id'], 1)
self.assertEquals(result['domain_count'], 2) self.assertEqual(result['domain_count'], 2)
self.assertItemsEqual(result['domains'], self.assertEqual(sorted(result['domains']),
[domain_1['name'], domain_2['name']]) [domain_1['name'], domain_2['name']])
def test_count_tenants(self): def test_count_tenants(self):
# in the beginning, there should be nothing # in the beginning, there should be nothing
@ -536,7 +530,7 @@ class StorageTestCase(TestCase):
# Create the Initial Domain # Create the Initial Domain
self.create_domain() self.create_domain()
with self.assertRaises(exceptions.DuplicateDomain): with testtools.ExpectedException(exceptions.DuplicateDomain):
self.create_domain() self.create_domain()
def test_find_domains(self): def test_find_domains(self):
@ -596,7 +590,7 @@ class StorageTestCase(TestCase):
self.assertIn('status', actual) self.assertIn('status', actual)
def test_get_domain_missing(self): def test_get_domain_missing(self):
with self.assertRaises(exceptions.DomainNotFound): with testtools.ExpectedException(exceptions.DomainNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.get_domain(self.admin_context, uuid) self.storage.get_domain(self.admin_context, uuid)
@ -641,7 +635,7 @@ class StorageTestCase(TestCase):
name=expected['name'] + "NOT FOUND" name=expected['name'] + "NOT FOUND"
) )
with self.assertRaises(exceptions.DomainNotFound): with testtools.ExpectedException(exceptions.DomainNotFound):
self.storage.find_domain(self.admin_context, criterion) self.storage.find_domain(self.admin_context, criterion)
def test_update_domain(self): def test_update_domain(self):
@ -660,12 +654,12 @@ class StorageTestCase(TestCase):
fixture_one, domain_one = self.create_domain(fixture=0) fixture_one, domain_one = self.create_domain(fixture=0)
_, domain_two = self.create_domain(fixture=1) _, domain_two = self.create_domain(fixture=1)
with self.assertRaises(exceptions.DuplicateDomain): with testtools.ExpectedException(exceptions.DuplicateDomain):
self.storage.update_domain(self.admin_context, domain_two['id'], self.storage.update_domain(self.admin_context, domain_two['id'],
fixture_one) fixture_one)
def test_update_domain_missing(self): def test_update_domain_missing(self):
with self.assertRaises(exceptions.DomainNotFound): with testtools.ExpectedException(exceptions.DomainNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.update_domain(self.admin_context, uuid, {}) self.storage.update_domain(self.admin_context, uuid, {})
@ -674,11 +668,11 @@ class StorageTestCase(TestCase):
self.storage.delete_domain(self.admin_context, domain['id']) self.storage.delete_domain(self.admin_context, domain['id'])
with self.assertRaises(exceptions.DomainNotFound): with testtools.ExpectedException(exceptions.DomainNotFound):
self.storage.get_domain(self.admin_context, domain['id']) self.storage.get_domain(self.admin_context, domain['id'])
def test_delete_domain_missing(self): def test_delete_domain_missing(self):
with self.assertRaises(exceptions.DomainNotFound): with testtools.ExpectedException(exceptions.DomainNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.delete_domain(self.admin_context, uuid) self.storage.delete_domain(self.admin_context, uuid)
@ -724,7 +718,7 @@ class StorageTestCase(TestCase):
# Create the First Record # Create the First Record
self.create_record(domain) self.create_record(domain)
with self.assertRaises(exceptions.DuplicateRecord): with testtools.ExpectedException(exceptions.DuplicateRecord):
# Attempt to create the second/duplicate record # Attempt to create the second/duplicate record
self.create_record(domain) self.create_record(domain)
@ -807,7 +801,7 @@ class StorageTestCase(TestCase):
self.assertIn('status', actual) self.assertIn('status', actual)
def test_get_record_missing(self): def test_get_record_missing(self):
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.get_record(self.admin_context, uuid) self.storage.get_record(self.admin_context, uuid)
@ -835,7 +829,7 @@ class StorageTestCase(TestCase):
name=expected['name'] + "NOT FOUND" name=expected['name'] + "NOT FOUND"
) )
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
self.storage.find_record(self.admin_context, domain['id'], self.storage.find_record(self.admin_context, domain['id'],
criterion) criterion)
@ -867,13 +861,13 @@ class StorageTestCase(TestCase):
record_one_fixture, _ = self.create_record(domain, fixture=0) record_one_fixture, _ = self.create_record(domain, fixture=0)
_, record_two = self.create_record(domain, fixture=1) _, record_two = self.create_record(domain, fixture=1)
with self.assertRaises(exceptions.DuplicateRecord): with testtools.ExpectedException(exceptions.DuplicateRecord):
# Attempt to update the second record, making it a duplicate record # Attempt to update the second record, making it a duplicate record
self.storage.update_record(self.admin_context, record_two['id'], self.storage.update_record(self.admin_context, record_two['id'],
record_one_fixture) record_one_fixture)
def test_update_record_missing(self): def test_update_record_missing(self):
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.update_record(self.admin_context, uuid, {}) self.storage.update_record(self.admin_context, uuid, {})
@ -885,11 +879,11 @@ class StorageTestCase(TestCase):
self.storage.delete_record(self.admin_context, record['id']) self.storage.delete_record(self.admin_context, record['id'])
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
self.storage.get_record(self.admin_context, record['id']) self.storage.get_record(self.admin_context, record['id'])
def test_delete_record_missing(self): def test_delete_record_missing(self):
with self.assertRaises(exceptions.RecordNotFound): with testtools.ExpectedException(exceptions.RecordNotFound):
uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b'
self.storage.delete_record(self.admin_context, uuid) self.storage.delete_record(self.admin_context, uuid)

View File

@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock import mock
import testtools
from designate.openstack.common import log as logging from designate.openstack.common import log as logging
from designate.tests import TestCase from designate.tests import TestCase
from designate.storage import api as storage_api from designate.storage import api as storage_api
@ -26,8 +27,6 @@ class SentinelException(Exception):
class StorageAPITest(TestCase): class StorageAPITest(TestCase):
__test__ = True
def setUp(self): def setUp(self):
super(StorageAPITest, self).setUp() super(StorageAPITest, self).setUp()
self.storage_api = storage_api.StorageAPI() self.storage_api = storage_api.StorageAPI()
@ -69,7 +68,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('create_quota', [{'id': 12345}]) self._set_side_effect('create_quota', [{'id': 12345}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.create_quota(context, values): with self.storage_api.create_quota(context, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -85,7 +84,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.get_quota(context, quota_id) result = self.storage_api.get_quota(context, quota_id)
self._assert_called_with('get_quota', context, quota_id) self._assert_called_with('get_quota', context, quota_id)
self.assertEquals(quota, result) self.assertEqual(quota, result)
def test_find_quotas(self): def test_find_quotas(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -96,7 +95,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_quotas(context, criterion) result = self.storage_api.find_quotas(context, criterion)
self._assert_called_with('find_quotas', context, criterion) self._assert_called_with('find_quotas', context, criterion)
self.assertEquals([quota], result) self.assertEqual([quota], result)
def test_find_quota(self): def test_find_quota(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -107,7 +106,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_quota(context, criterion) result = self.storage_api.find_quota(context, criterion)
self._assert_called_with('find_quota', context, criterion) self._assert_called_with('find_quota', context, criterion)
self.assertEquals(quota, result) self.assertEqual(quota, result)
def test_update_quota(self): def test_update_quota(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -124,7 +123,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_quota', [{'id': 123, 'test': 1}]) self._set_side_effect('get_quota', [{'id': 123, 'test': 1}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.update_quota(context, 123, values): with self.storage_api.update_quota(context, 123, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -140,7 +139,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_quota', [quota]) self._set_side_effect('get_quota', [quota])
with self.storage_api.delete_quota(context, 123) as q: with self.storage_api.delete_quota(context, 123) as q:
self.assertEquals(quota, q) self.assertEqual(quota, q)
self._assert_called_with('delete_quota', context, 123) self._assert_called_with('delete_quota', context, 123)
@ -150,7 +149,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_quota', [quota]) self._set_side_effect('get_quota', [quota])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.delete_quota(context, 123): with self.storage_api.delete_quota(context, 123):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -175,7 +174,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('create_server', [{'id': 12345}]) self._set_side_effect('create_server', [{'id': 12345}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.create_server(context, values): with self.storage_api.create_server(context, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -191,7 +190,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.get_server(context, server_id) result = self.storage_api.get_server(context, server_id)
self._assert_called_with('get_server', context, server_id) self._assert_called_with('get_server', context, server_id)
self.assertEquals(server, result) self.assertEqual(server, result)
def test_find_servers(self): def test_find_servers(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -202,7 +201,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_servers(context, criterion) result = self.storage_api.find_servers(context, criterion)
self._assert_called_with('find_servers', context, criterion) self._assert_called_with('find_servers', context, criterion)
self.assertEquals([server], result) self.assertEqual([server], result)
def test_find_server(self): def test_find_server(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -213,7 +212,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_server(context, criterion) result = self.storage_api.find_server(context, criterion)
self._assert_called_with('find_server', context, criterion) self._assert_called_with('find_server', context, criterion)
self.assertEquals(server, result) self.assertEqual(server, result)
def test_update_server(self): def test_update_server(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -230,7 +229,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_server', [{'id': 123, 'test': 1}]) self._set_side_effect('get_server', [{'id': 123, 'test': 1}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.update_server(context, 123, values): with self.storage_api.update_server(context, 123, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -246,7 +245,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_server', [server]) self._set_side_effect('get_server', [server])
with self.storage_api.delete_server(context, 123) as q: with self.storage_api.delete_server(context, 123) as q:
self.assertEquals(server, q) self.assertEqual(server, q)
self._assert_called_with('delete_server', context, 123) self._assert_called_with('delete_server', context, 123)
@ -256,7 +255,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_server', [server]) self._set_side_effect('get_server', [server])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.delete_server(context, 123): with self.storage_api.delete_server(context, 123):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -281,7 +280,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('create_tsigkey', [{'id': 12345}]) self._set_side_effect('create_tsigkey', [{'id': 12345}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.create_tsigkey(context, values): with self.storage_api.create_tsigkey(context, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -297,7 +296,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.get_tsigkey(context, tsigkey_id) result = self.storage_api.get_tsigkey(context, tsigkey_id)
self._assert_called_with('get_tsigkey', context, tsigkey_id) self._assert_called_with('get_tsigkey', context, tsigkey_id)
self.assertEquals(tsigkey, result) self.assertEqual(tsigkey, result)
def test_find_tsigkeys(self): def test_find_tsigkeys(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -308,7 +307,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_tsigkeys(context, criterion) result = self.storage_api.find_tsigkeys(context, criterion)
self._assert_called_with('find_tsigkeys', context, criterion) self._assert_called_with('find_tsigkeys', context, criterion)
self.assertEquals([tsigkey], result) self.assertEqual([tsigkey], result)
def test_find_tsigkey(self): def test_find_tsigkey(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -319,7 +318,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_tsigkey(context, criterion) result = self.storage_api.find_tsigkey(context, criterion)
self._assert_called_with('find_tsigkey', context, criterion) self._assert_called_with('find_tsigkey', context, criterion)
self.assertEquals(tsigkey, result) self.assertEqual(tsigkey, result)
def test_update_tsigkey(self): def test_update_tsigkey(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -336,7 +335,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_tsigkey', [{'id': 123, 'test': 1}]) self._set_side_effect('get_tsigkey', [{'id': 123, 'test': 1}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.update_tsigkey(context, 123, values): with self.storage_api.update_tsigkey(context, 123, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -352,7 +351,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_tsigkey', [tsigkey]) self._set_side_effect('get_tsigkey', [tsigkey])
with self.storage_api.delete_tsigkey(context, 123) as q: with self.storage_api.delete_tsigkey(context, 123) as q:
self.assertEquals(tsigkey, q) self.assertEqual(tsigkey, q)
self._assert_called_with('delete_tsigkey', context, 123) self._assert_called_with('delete_tsigkey', context, 123)
@ -362,7 +361,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_tsigkey', [tsigkey]) self._set_side_effect('get_tsigkey', [tsigkey])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.delete_tsigkey(context, 123): with self.storage_api.delete_tsigkey(context, 123):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -377,7 +376,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_tenants(context) result = self.storage_api.find_tenants(context)
self._assert_called_with('find_tenants', context) self._assert_called_with('find_tenants', context)
self.assertEquals([tenant], result) self.assertEqual([tenant], result)
def test_get_tenant(self): def test_get_tenant(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -387,7 +386,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.get_tenant(context, 123) result = self.storage_api.get_tenant(context, 123)
self._assert_called_with('get_tenant', context, 123) self._assert_called_with('get_tenant', context, 123)
self.assertEquals(tenant, result) self.assertEqual(tenant, result)
def test_count_tenants(self): def test_count_tenants(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -396,7 +395,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.count_tenants(context) result = self.storage_api.count_tenants(context)
self._assert_called_with('count_tenants', context) self._assert_called_with('count_tenants', context)
self.assertEquals(1, result) self.assertEqual(1, result)
# Domain Tests # Domain Tests
def test_create_domain(self): def test_create_domain(self):
@ -417,7 +416,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('create_domain', [{'id': 12345}]) self._set_side_effect('create_domain', [{'id': 12345}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.create_domain(context, values): with self.storage_api.create_domain(context, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -433,7 +432,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.get_domain(context, domain_id) result = self.storage_api.get_domain(context, domain_id)
self._assert_called_with('get_domain', context, domain_id) self._assert_called_with('get_domain', context, domain_id)
self.assertEquals(domain, result) self.assertEqual(domain, result)
def test_find_domains(self): def test_find_domains(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -444,7 +443,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_domains(context, criterion) result = self.storage_api.find_domains(context, criterion)
self._assert_called_with('find_domains', context, criterion) self._assert_called_with('find_domains', context, criterion)
self.assertEquals([domain], result) self.assertEqual([domain], result)
def test_find_domain(self): def test_find_domain(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -455,7 +454,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_domain(context, criterion) result = self.storage_api.find_domain(context, criterion)
self._assert_called_with('find_domain', context, criterion) self._assert_called_with('find_domain', context, criterion)
self.assertEquals(domain, result) self.assertEqual(domain, result)
def test_update_domain(self): def test_update_domain(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -472,7 +471,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_domain', [{'id': 123, 'test': 1}]) self._set_side_effect('get_domain', [{'id': 123, 'test': 1}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.update_domain(context, 123, values): with self.storage_api.update_domain(context, 123, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -488,7 +487,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_domain', [domain]) self._set_side_effect('get_domain', [domain])
with self.storage_api.delete_domain(context, 123) as q: with self.storage_api.delete_domain(context, 123) as q:
self.assertEquals(domain, q) self.assertEqual(domain, q)
self._assert_called_with('delete_domain', context, 123) self._assert_called_with('delete_domain', context, 123)
@ -498,7 +497,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_domain', [domain]) self._set_side_effect('get_domain', [domain])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.delete_domain(context, 123): with self.storage_api.delete_domain(context, 123):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -523,7 +522,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('create_record', [{'id': 12345}]) self._set_side_effect('create_record', [{'id': 12345}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.create_record(context, 123, values): with self.storage_api.create_record(context, 123, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -539,7 +538,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.get_record(context, record_id) result = self.storage_api.get_record(context, record_id)
self._assert_called_with('get_record', context, record_id) self._assert_called_with('get_record', context, record_id)
self.assertEquals(record, result) self.assertEqual(record, result)
def test_find_records(self): def test_find_records(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -551,7 +550,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_records(context, domain_id, criterion) result = self.storage_api.find_records(context, domain_id, criterion)
self._assert_called_with('find_records', context, domain_id, criterion) self._assert_called_with('find_records', context, domain_id, criterion)
self.assertEquals([record], result) self.assertEqual([record], result)
def test_find_record(self): def test_find_record(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -563,7 +562,7 @@ class StorageAPITest(TestCase):
result = self.storage_api.find_record(context, domain_id, criterion) result = self.storage_api.find_record(context, domain_id, criterion)
self._assert_called_with('find_record', context, domain_id, criterion) self._assert_called_with('find_record', context, domain_id, criterion)
self.assertEquals(record, result) self.assertEqual(record, result)
def test_update_record(self): def test_update_record(self):
context = mock.sentinel.context context = mock.sentinel.context
@ -580,7 +579,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_record', [{'id': 123, 'test': 1}]) self._set_side_effect('get_record', [{'id': 123, 'test': 1}])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.update_record(context, 123, values): with self.storage_api.update_record(context, 123, values):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')
@ -596,7 +595,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_record', [record]) self._set_side_effect('get_record', [record])
with self.storage_api.delete_record(context, 123) as q: with self.storage_api.delete_record(context, 123) as q:
self.assertEquals(record, q) self.assertEqual(record, q)
self._assert_called_with('delete_record', context, 123) self._assert_called_with('delete_record', context, 123)
@ -606,7 +605,7 @@ class StorageAPITest(TestCase):
self._set_side_effect('get_record', [record]) self._set_side_effect('get_record', [record])
with self.assertRaises(SentinelException): with testtools.ExpectedException(SentinelException):
with self.storage_api.delete_record(context, 123): with self.storage_api.delete_record(context, 123):
raise SentinelException('Something Went Wrong') raise SentinelException('Something Went Wrong')

View File

@ -19,6 +19,8 @@ from migrate.versioning import api as versioning_api
from migrate.versioning import repository from migrate.versioning import repository
import sqlalchemy import sqlalchemy
from designate.openstack.common import log as logging from designate.openstack.common import log as logging
from designate import storage
from designate.tests import TestCase
from designate.tests.test_storage import StorageTestCase from designate.tests.test_storage import StorageTestCase
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -27,21 +29,18 @@ REPOSITORY = os.path.abspath(os.path.join(os.path.dirname(__file__), '..',
'migrate_repo')) 'migrate_repo'))
class SqlalchemyStorageTest(StorageTestCase): class SqlalchemyStorageTest(StorageTestCase, TestCase):
__test__ = True
def setUp(self): def setUp(self):
self.config(database_connection='sqlite://', self.config(database_connection='sqlite://',
group='storage:sqlalchemy') group='storage:sqlalchemy')
super(SqlalchemyStorageTest, self).setUp() super(SqlalchemyStorageTest, self).setUp()
self.storage = storage.get_storage()
self.REPOSITORY = repository.Repository(REPOSITORY) self.REPOSITORY = repository.Repository(REPOSITORY)
# Migration Test Stuff # Migration Test Stuff
def _init_database(self, url): def _init_database(self, url):
LOG.debug('Building Engine') LOG.debug('Building Engine')
engine = sqlalchemy.create_engine(url) engine = sqlalchemy.create_engine(url)
LOG.debug('Initializing database') LOG.debug('Initializing database')
versioning_api.version_control(engine, repository=self.REPOSITORY) versioning_api.version_control(engine, repository=self.REPOSITORY)

View File

@ -15,6 +15,7 @@
# under the License. # under the License.
import os import os
import tempfile import tempfile
import testtools
from jinja2 import Template from jinja2 import Template
from designate.tests import TestCase from designate.tests import TestCase
from designate import exceptions from designate import exceptions
@ -32,7 +33,7 @@ class TestUtils(TestCase):
def test_resource_string_missing(self): def test_resource_string_missing(self):
name = 'invalid.jinja2' name = 'invalid.jinja2'
with self.assertRaises(exceptions.ResourceNotFound): with testtools.ExpectedException(exceptions.ResourceNotFound):
utils.resource_string(name) utils.resource_string(name)
def test_load_schema(self): def test_load_schema(self):
@ -41,7 +42,7 @@ class TestUtils(TestCase):
self.assertIsInstance(schema, dict) self.assertIsInstance(schema, dict)
def test_load_schema_missing(self): def test_load_schema_missing(self):
with self.assertRaises(exceptions.ResourceNotFound): with testtools.ExpectedException(exceptions.ResourceNotFound):
utils.load_schema('v1', 'missing') utils.load_schema('v1', 'missing')
def test_load_template(self): def test_load_template(self):
@ -54,7 +55,7 @@ class TestUtils(TestCase):
def test_load_template_missing(self): def test_load_template_missing(self):
name = 'invalid.jinja2' name = 'invalid.jinja2'
with self.assertRaises(exceptions.ResourceNotFound): with testtools.ExpectedException(exceptions.ResourceNotFound):
utils.load_template(name) utils.load_template(name)
def test_render_template(self): def test_render_template(self):

View File

@ -12,6 +12,7 @@ module=processutils
module=rootwrap module=rootwrap
module=rpc module=rpc
module=service module=service
module=test
module=timeutils module=timeutils
module=uuidutils module=uuidutils
module=wsgi module=wsgi

View File

@ -1,13 +1,13 @@
coverage>=3.6 coverage>=3.6
discover
flake8==2.0 flake8==2.0
hacking>=0.5.6,<0.8 fixtures>=0.3.14
hacking>=0.8,<0.9
mock>=1.0 mock>=1.0
mox>=0.5.3 mox>=0.5.3
nose
nosehtmloutput>=0.0.3
nosexcover
openstack.nose_plugin>=0.7
pep8==1.4.5 pep8==1.4.5
pyflakes>=0.7.2,<0.7.4 pyflakes>=0.7.2,<0.7.4
unittest2 python-subunit
testtools>=0.9.32
testrepository>=0.0.8
WebTest>=2.0 WebTest>=2.0

14
tox.ini
View File

@ -7,24 +7,14 @@ skipsdist = True
downloadcache = ~/cache/pip downloadcache = ~/cache/pip
[testenv] [testenv]
sitepackages = False
usedevelop = True usedevelop = True
install_command = pip install {opts} {packages} 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
setenv = VIRTUAL_ENV={envdir} commands = python setup.py testr --slowest --testr-args='{posargs}'
NOSE_WITH_OPENSTACK=1
NOSE_OPENSTACK_COLOR=1
NOSE_OPENSTACK_RED=0.05
NOSE_OPENSTACK_YELLOW=0.025
NOSE_OPENSTACK_SHOW_ELAPSED=1
commands = nosetests {posargs}
[testenv:cover] [testenv:cover]
setenv = {[testenv]setenv} commands = python setup.py testr --coverage --testr-args='{posargs}'
NOSE_WITH_COVERAGE=1
NOSE_COVER_PACKAGE=designate
NOSE_COVER_INCLUSIVE=1
[testenv:flake8] [testenv:flake8]
commands = flake8 commands = flake8