summaryrefslogtreecommitdiff
path: root/taskflow/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-12-18 23:42:35 +0000
committerGerrit Code Review <review@openstack.org>2014-12-18 23:42:35 +0000
commitba62a9c7be999f49d89af6c5e0636f6f89bbdd13 (patch)
tree41d1f83e32607a40c20a7a7ddb30b10a2ce64141 /taskflow/tests
parent0cf641b0c294b5d653f4377248d6b3df358f104b (diff)
parent4e514f41e57983e728db9025126df6f791a2594a (diff)
downloadtaskflow-0.6.0.tar.gz
Merge "Move over to using oslo.utils [reflection, uuidutils]"0.6.0
Diffstat (limited to 'taskflow/tests')
-rw-r--r--taskflow/tests/unit/jobs/base.py2
-rw-r--r--taskflow/tests/unit/jobs/test_zk_job.py2
-rw-r--r--taskflow/tests/unit/persistence/base.py3
-rw-r--r--taskflow/tests/unit/persistence/test_zk_persistence.py2
-rw-r--r--taskflow/tests/unit/test_listeners.py2
-rw-r--r--taskflow/tests/unit/test_storage.py3
-rw-r--r--taskflow/tests/unit/test_utils.py255
-rw-r--r--taskflow/tests/unit/worker_based/test_endpoint.py3
-rw-r--r--taskflow/tests/unit/worker_based/test_message_pump.py3
-rw-r--r--taskflow/tests/unit/worker_based/test_pipeline.py2
-rw-r--r--taskflow/tests/unit/worker_based/test_protocol.py2
-rw-r--r--taskflow/tests/unit/worker_based/test_worker.py2
12 files changed, 15 insertions, 266 deletions
diff --git a/taskflow/tests/unit/jobs/base.py b/taskflow/tests/unit/jobs/base.py
index 24da7d3..4c070f3 100644
--- a/taskflow/tests/unit/jobs/base.py
+++ b/taskflow/tests/unit/jobs/base.py
@@ -18,9 +18,9 @@ import contextlib
import time
from kazoo.recipe import watchers
+from oslo.utils import uuidutils
from taskflow import exceptions as excp
-from taskflow.openstack.common import uuidutils
from taskflow.persistence.backends import impl_dir
from taskflow import states
from taskflow.test import mock
diff --git a/taskflow/tests/unit/jobs/test_zk_job.py b/taskflow/tests/unit/jobs/test_zk_job.py
index 5a536f9..8737a4f 100644
--- a/taskflow/tests/unit/jobs/test_zk_job.py
+++ b/taskflow/tests/unit/jobs/test_zk_job.py
@@ -15,13 +15,13 @@
# under the License.
from oslo.serialization import jsonutils
+from oslo.utils import uuidutils
import six
import testtools
from zake import fake_client
from zake import utils as zake_utils
from taskflow.jobs.backends import impl_zookeeper
-from taskflow.openstack.common import uuidutils
from taskflow import states
from taskflow import test
from taskflow.tests.unit.jobs import base
diff --git a/taskflow/tests/unit/persistence/base.py b/taskflow/tests/unit/persistence/base.py
index 50bb3b3..88660fd 100644
--- a/taskflow/tests/unit/persistence/base.py
+++ b/taskflow/tests/unit/persistence/base.py
@@ -16,8 +16,9 @@
import contextlib
+from oslo.utils import uuidutils
+
from taskflow import exceptions as exc
-from taskflow.openstack.common import uuidutils
from taskflow.persistence import logbook
from taskflow import states
from taskflow.types import failure
diff --git a/taskflow/tests/unit/persistence/test_zk_persistence.py b/taskflow/tests/unit/persistence/test_zk_persistence.py
index 609de21..28463bb 100644
--- a/taskflow/tests/unit/persistence/test_zk_persistence.py
+++ b/taskflow/tests/unit/persistence/test_zk_persistence.py
@@ -17,11 +17,11 @@
import contextlib
from kazoo import exceptions as kazoo_exceptions
+from oslo.utils import uuidutils
import testtools
from zake import fake_client
from taskflow import exceptions as exc
-from taskflow.openstack.common import uuidutils
from taskflow.persistence import backends
from taskflow.persistence.backends import impl_zookeeper
from taskflow import test
diff --git a/taskflow/tests/unit/test_listeners.py b/taskflow/tests/unit/test_listeners.py
index 210fe79..c10bc28 100644
--- a/taskflow/tests/unit/test_listeners.py
+++ b/taskflow/tests/unit/test_listeners.py
@@ -19,6 +19,7 @@ import logging
import time
from oslo.serialization import jsonutils
+from oslo.utils import reflection
import six
from zake import fake_client
@@ -37,7 +38,6 @@ from taskflow.test import mock
from taskflow.tests import utils as test_utils
from taskflow.utils import misc
from taskflow.utils import persistence_utils
-from taskflow.utils import reflection
from taskflow.utils import threading_utils
diff --git a/taskflow/tests/unit/test_storage.py b/taskflow/tests/unit/test_storage.py
index f774993..886e075 100644
--- a/taskflow/tests/unit/test_storage.py
+++ b/taskflow/tests/unit/test_storage.py
@@ -17,8 +17,9 @@
import contextlib
import threading
+from oslo.utils import uuidutils
+
from taskflow import exceptions
-from taskflow.openstack.common import uuidutils
from taskflow.persistence import backends
from taskflow.persistence import logbook
from taskflow import states
diff --git a/taskflow/tests/unit/test_utils.py b/taskflow/tests/unit/test_utils.py
index 56e3919..c69b769 100644
--- a/taskflow/tests/unit/test_utils.py
+++ b/taskflow/tests/unit/test_utils.py
@@ -19,266 +19,11 @@ import inspect
import random
import time
-import six
-import testtools
-
from taskflow import test
-from taskflow.tests import utils as test_utils
-from taskflow.types import failure
-from taskflow.utils import lock_utils
from taskflow.utils import misc
-from taskflow.utils import reflection
from taskflow.utils import threading_utils
-def mere_function(a, b):
- pass
-
-
-def function_with_defs(a, b, optional=None):
- pass
-
-
-def function_with_kwargs(a, b, **kwargs):
- pass
-
-
-class Class(object):
-
- def method(self, c, d):
- pass
-
- @staticmethod
- def static_method(e, f):
- pass
-
- @classmethod
- def class_method(cls, g, h):
- pass
-
-
-class CallableClass(object):
- def __call__(self, i, j):
- pass
-
-
-class ClassWithInit(object):
- def __init__(self, k, l):
- pass
-
-
-class CallbackEqualityTest(test.TestCase):
- def test_different_simple_callbacks(self):
-
- def a():
- pass
-
- def b():
- pass
-
- self.assertFalse(reflection.is_same_callback(a, b))
-
- def test_static_instance_callbacks(self):
-
- class A(object):
-
- @staticmethod
- def b(a, b, c):
- pass
-
- a = A()
- b = A()
-
- self.assertTrue(reflection.is_same_callback(a.b, b.b))
-
- def test_different_instance_callbacks(self):
-
- class A(object):
- def b(self):
- pass
-
- def __eq__(self, other):
- return True
-
- b = A()
- c = A()
-
- self.assertFalse(reflection.is_same_callback(b.b, c.b))
- self.assertTrue(reflection.is_same_callback(b.b, c.b, strict=False))
-
-
-class GetCallableNameTest(test.TestCase):
-
- def test_mere_function(self):
- name = reflection.get_callable_name(mere_function)
- self.assertEqual(name, '.'.join((__name__, 'mere_function')))
-
- def test_method(self):
- name = reflection.get_callable_name(Class.method)
- self.assertEqual(name, '.'.join((__name__, 'Class', 'method')))
-
- def test_instance_method(self):
- name = reflection.get_callable_name(Class().method)
- self.assertEqual(name, '.'.join((__name__, 'Class', 'method')))
-
- def test_static_method(self):
- name = reflection.get_callable_name(Class.static_method)
- if six.PY3:
- self.assertEqual(name,
- '.'.join((__name__, 'Class', 'static_method')))
- else:
- # NOTE(imelnikov): static method are just functions, class name
- # is not recorded anywhere in them.
- self.assertEqual(name,
- '.'.join((__name__, 'static_method')))
-
- def test_class_method(self):
- name = reflection.get_callable_name(Class.class_method)
- self.assertEqual(name, '.'.join((__name__, 'Class', 'class_method')))
-
- def test_constructor(self):
- name = reflection.get_callable_name(Class)
- self.assertEqual(name, '.'.join((__name__, 'Class')))
-
- def test_callable_class(self):
- name = reflection.get_callable_name(CallableClass())
- self.assertEqual(name, '.'.join((__name__, 'CallableClass')))
-
- def test_callable_class_call(self):
- name = reflection.get_callable_name(CallableClass().__call__)
- self.assertEqual(name, '.'.join((__name__, 'CallableClass',
- '__call__')))
-
-
-# These extended/special case tests only work on python 3, due to python 2
-# being broken/incorrect with regard to these special cases...
-@testtools.skipIf(not six.PY3, 'python 3.x is not currently available')
-class GetCallableNameTestExtended(test.TestCase):
- # Tests items in http://legacy.python.org/dev/peps/pep-3155/
-
- class InnerCallableClass(object):
- def __call__(self):
- pass
-
- def test_inner_callable_class(self):
- obj = self.InnerCallableClass()
- name = reflection.get_callable_name(obj.__call__)
- expected_name = '.'.join((__name__, 'GetCallableNameTestExtended',
- 'InnerCallableClass', '__call__'))
- self.assertEqual(expected_name, name)
-
- def test_inner_callable_function(self):
- def a():
-
- def b():
- pass
-
- return b
-
- name = reflection.get_callable_name(a())
- expected_name = '.'.join((__name__, 'GetCallableNameTestExtended',
- 'test_inner_callable_function', '<locals>',
- 'a', '<locals>', 'b'))
- self.assertEqual(expected_name, name)
-
- def test_inner_class(self):
- obj = self.InnerCallableClass()
- name = reflection.get_callable_name(obj)
- expected_name = '.'.join((__name__,
- 'GetCallableNameTestExtended',
- 'InnerCallableClass'))
- self.assertEqual(expected_name, name)
-
-
-class GetCallableArgsTest(test.TestCase):
-
- def test_mere_function(self):
- result = reflection.get_callable_args(mere_function)
- self.assertEqual(['a', 'b'], result)
-
- def test_function_with_defaults(self):
- result = reflection.get_callable_args(function_with_defs)
- self.assertEqual(['a', 'b', 'optional'], result)
-
- def test_required_only(self):
- result = reflection.get_callable_args(function_with_defs,
- required_only=True)
- self.assertEqual(['a', 'b'], result)
-
- def test_method(self):
- result = reflection.get_callable_args(Class.method)
- self.assertEqual(['self', 'c', 'd'], result)
-
- def test_instance_method(self):
- result = reflection.get_callable_args(Class().method)
- self.assertEqual(['c', 'd'], result)
-
- def test_class_method(self):
- result = reflection.get_callable_args(Class.class_method)
- self.assertEqual(['g', 'h'], result)
-
- def test_class_constructor(self):
- result = reflection.get_callable_args(ClassWithInit)
- self.assertEqual(['k', 'l'], result)
-
- def test_class_with_call(self):
- result = reflection.get_callable_args(CallableClass())
- self.assertEqual(['i', 'j'], result)
-
- def test_decorators_work(self):
- @lock_utils.locked
- def locked_fun(x, y):
- pass
- result = reflection.get_callable_args(locked_fun)
- self.assertEqual(['x', 'y'], result)
-
-
-class AcceptsKwargsTest(test.TestCase):
-
- def test_no_kwargs(self):
- self.assertEqual(
- reflection.accepts_kwargs(mere_function), False)
-
- def test_with_kwargs(self):
- self.assertEqual(
- reflection.accepts_kwargs(function_with_kwargs), True)
-
-
-class GetClassNameTest(test.TestCase):
-
- def test_std_exception(self):
- name = reflection.get_class_name(RuntimeError)
- self.assertEqual(name, 'RuntimeError')
-
- def test_global_class(self):
- name = reflection.get_class_name(failure.Failure)
- self.assertEqual(name, 'taskflow.types.failure.Failure')
-
- def test_class(self):
- name = reflection.get_class_name(Class)
- self.assertEqual(name, '.'.join((__name__, 'Class')))
-
- def test_instance(self):
- name = reflection.get_class_name(Class())
- self.assertEqual(name, '.'.join((__name__, 'Class')))
-
- def test_int(self):
- name = reflection.get_class_name(42)
- self.assertEqual(name, 'int')
-
-
-class GetAllClassNamesTest(test.TestCase):
-
- def test_std_class(self):
- names = list(reflection.get_all_class_names(RuntimeError))
- self.assertEqual(names, test_utils.RUNTIME_ERROR_CLASSES)
-
- def test_std_class_up_to(self):
- names = list(reflection.get_all_class_names(RuntimeError,
- up_to=Exception))
- self.assertEqual(names, test_utils.RUNTIME_ERROR_CLASSES[:-2])
-
-
class CachedPropertyTest(test.TestCase):
def test_attribute_caching(self):
diff --git a/taskflow/tests/unit/worker_based/test_endpoint.py b/taskflow/tests/unit/worker_based/test_endpoint.py
index 36abb98..53260b1 100644
--- a/taskflow/tests/unit/worker_based/test_endpoint.py
+++ b/taskflow/tests/unit/worker_based/test_endpoint.py
@@ -14,11 +14,12 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.utils import reflection
+
from taskflow.engines.worker_based import endpoint as ep
from taskflow import task
from taskflow import test
from taskflow.tests import utils
-from taskflow.utils import reflection
class Task(task.Task):
diff --git a/taskflow/tests/unit/worker_based/test_message_pump.py b/taskflow/tests/unit/worker_based/test_message_pump.py
index cae4fa5..7b945a2 100644
--- a/taskflow/tests/unit/worker_based/test_message_pump.py
+++ b/taskflow/tests/unit/worker_based/test_message_pump.py
@@ -14,9 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.utils import uuidutils
+
from taskflow.engines.worker_based import protocol as pr
from taskflow.engines.worker_based import proxy
-from taskflow.openstack.common import uuidutils
from taskflow import test
from taskflow.test import mock
from taskflow.tests import utils as test_utils
diff --git a/taskflow/tests/unit/worker_based/test_pipeline.py b/taskflow/tests/unit/worker_based/test_pipeline.py
index 2822a85..53bf8f9 100644
--- a/taskflow/tests/unit/worker_based/test_pipeline.py
+++ b/taskflow/tests/unit/worker_based/test_pipeline.py
@@ -15,12 +15,12 @@
# under the License.
from concurrent import futures
+from oslo.utils import uuidutils
from taskflow.engines.action_engine import executor as base_executor
from taskflow.engines.worker_based import endpoint
from taskflow.engines.worker_based import executor as worker_executor
from taskflow.engines.worker_based import server as worker_server
-from taskflow.openstack.common import uuidutils
from taskflow import test
from taskflow.tests import utils as test_utils
from taskflow.types import failure
diff --git a/taskflow/tests/unit/worker_based/test_protocol.py b/taskflow/tests/unit/worker_based/test_protocol.py
index d2f2cc0..4c34ed6 100644
--- a/taskflow/tests/unit/worker_based/test_protocol.py
+++ b/taskflow/tests/unit/worker_based/test_protocol.py
@@ -16,11 +16,11 @@
from concurrent import futures
from oslo.utils import timeutils
+from oslo.utils import uuidutils
from taskflow.engines.action_engine import executor
from taskflow.engines.worker_based import protocol as pr
from taskflow import exceptions as excp
-from taskflow.openstack.common import uuidutils
from taskflow import test
from taskflow.tests import utils
from taskflow.types import failure
diff --git a/taskflow/tests/unit/worker_based/test_worker.py b/taskflow/tests/unit/worker_based/test_worker.py
index ff049a6..8fc76eb 100644
--- a/taskflow/tests/unit/worker_based/test_worker.py
+++ b/taskflow/tests/unit/worker_based/test_worker.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from oslo.utils import reflection
import six
from taskflow.engines.worker_based import endpoint
@@ -21,7 +22,6 @@ from taskflow.engines.worker_based import worker
from taskflow import test
from taskflow.test import mock
from taskflow.tests import utils
-from taskflow.utils import reflection
class TestWorker(test.MockTestCase):