Update code to comply with hacking 0.8.0
Replace assertEquals and assertNotEquals with assertEqual and assertNotEqual (new rule, H234), and fix indentation. Change-Id: I86177325dee3aa00af5df8b3085acd478994ee34
This commit is contained in:
parent
31d25f25b8
commit
20a87636a3
@ -44,9 +44,9 @@ class PersistenceTestMixin(object):
|
||||
# we expect them to be).
|
||||
with contextlib.closing(self._get_connection()) as conn:
|
||||
lb = conn.get_logbook(lb_id)
|
||||
self.assertEquals(lb_name, lb.name)
|
||||
self.assertEquals(0, len(lb))
|
||||
self.assertEquals(lb_meta, lb.meta)
|
||||
self.assertEqual(lb_name, lb.name)
|
||||
self.assertEqual(0, len(lb))
|
||||
self.assertEqual(lb_meta, lb.meta)
|
||||
self.assertIsNone(lb.updated_at)
|
||||
self.assertIsNotNone(lb.created_at)
|
||||
|
||||
@ -117,9 +117,9 @@ class PersistenceTestMixin(object):
|
||||
fd2 = lb2.find(fd.uuid)
|
||||
td2 = fd2.find(td.uuid)
|
||||
failure = td2.failure
|
||||
self.assertEquals(failure.exception_str, 'Woot!')
|
||||
self.assertEqual(failure.exception_str, 'Woot!')
|
||||
self.assertIs(failure.check(RuntimeError), RuntimeError)
|
||||
self.assertEquals(failure.traceback_str, td.failure.traceback_str)
|
||||
self.assertEqual(failure.traceback_str, td.failure.traceback_str)
|
||||
|
||||
def test_logbook_merge_flow_detail(self):
|
||||
lb_id = uuidutils.generate_uuid()
|
||||
@ -136,7 +136,7 @@ class PersistenceTestMixin(object):
|
||||
conn.save_logbook(lb2)
|
||||
with contextlib.closing(self._get_connection()) as conn:
|
||||
lb3 = conn.get_logbook(lb_id)
|
||||
self.assertEquals(2, len(lb3))
|
||||
self.assertEqual(2, len(lb3))
|
||||
|
||||
def test_logbook_add_flow_detail(self):
|
||||
lb_id = uuidutils.generate_uuid()
|
||||
@ -148,9 +148,9 @@ class PersistenceTestMixin(object):
|
||||
conn.save_logbook(lb)
|
||||
with contextlib.closing(self._get_connection()) as conn:
|
||||
lb2 = conn.get_logbook(lb_id)
|
||||
self.assertEquals(1, len(lb2))
|
||||
self.assertEquals(1, len(lb))
|
||||
self.assertEquals(fd.name, lb2.find(fd.uuid).name)
|
||||
self.assertEqual(1, len(lb2))
|
||||
self.assertEqual(1, len(lb))
|
||||
self.assertEqual(fd.name, lb2.find(fd.uuid).name)
|
||||
|
||||
def test_logbook_add_task_detail(self):
|
||||
lb_id = uuidutils.generate_uuid()
|
||||
@ -165,18 +165,18 @@ class PersistenceTestMixin(object):
|
||||
conn.save_logbook(lb)
|
||||
with contextlib.closing(self._get_connection()) as conn:
|
||||
lb2 = conn.get_logbook(lb_id)
|
||||
self.assertEquals(1, len(lb2))
|
||||
self.assertEqual(1, len(lb2))
|
||||
tasks = 0
|
||||
for fd in lb:
|
||||
tasks += len(fd)
|
||||
self.assertEquals(1, tasks)
|
||||
self.assertEqual(1, tasks)
|
||||
with contextlib.closing(self._get_connection()) as conn:
|
||||
lb2 = conn.get_logbook(lb_id)
|
||||
fd2 = lb2.find(fd.uuid)
|
||||
td2 = fd2.find(td.uuid)
|
||||
self.assertIsNot(td2, None)
|
||||
self.assertEquals(td2.name, 'detail-1')
|
||||
self.assertEquals(td2.version, '4.2')
|
||||
self.assertEqual(td2.name, 'detail-1')
|
||||
self.assertEqual(td2.version, '4.2')
|
||||
|
||||
def test_logbook_delete(self):
|
||||
lb_id = uuidutils.generate_uuid()
|
||||
|
@ -41,7 +41,7 @@ class EngineTaskTest(utils.EngineTestBase):
|
||||
flow = utils.SaveOrderTask(self.values, name='task1')
|
||||
engine = self._make_engine(flow)
|
||||
engine.run()
|
||||
self.assertEquals(self.values, ['task1'])
|
||||
self.assertEqual(self.values, ['task1'])
|
||||
|
||||
@staticmethod
|
||||
def _callback(state, values, details):
|
||||
@ -60,12 +60,12 @@ class EngineTaskTest(utils.EngineTestBase):
|
||||
engine.task_notifier.register('*', self._callback,
|
||||
kwargs={'values': self.values})
|
||||
engine.run()
|
||||
self.assertEquals(self.values,
|
||||
['flow RUNNING',
|
||||
'task1 RUNNING',
|
||||
'task1',
|
||||
'task1 SUCCESS',
|
||||
'flow SUCCESS'])
|
||||
self.assertEqual(self.values,
|
||||
['flow RUNNING',
|
||||
'task1 RUNNING',
|
||||
'task1',
|
||||
'task1 SUCCESS',
|
||||
'flow SUCCESS'])
|
||||
|
||||
def test_failing_task_with_notifications(self):
|
||||
flow = utils.FailingTask(self.values, 'fail')
|
||||
@ -85,14 +85,14 @@ class EngineTaskTest(utils.EngineTestBase):
|
||||
'flow REVERTED']
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine.run()
|
||||
self.assertEquals(self.values, expected)
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.REVERTED)
|
||||
self.assertEqual(self.values, expected)
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.REVERTED)
|
||||
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine.run()
|
||||
now_expected = expected + ['fail PENDING', 'flow PENDING'] + expected
|
||||
self.assertEquals(self.values, now_expected)
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.REVERTED)
|
||||
self.assertEqual(self.values, now_expected)
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.REVERTED)
|
||||
|
||||
def test_invalid_flow_raises(self):
|
||||
value = 'i am string, not task/flow, sorry'
|
||||
@ -116,7 +116,7 @@ class EngineLinearFlowTest(utils.EngineTestBase):
|
||||
utils.SaveOrderTask(self.values, name='task1')
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(self.values, ['task1'])
|
||||
self.assertEqual(self.values, ['task1'])
|
||||
|
||||
def test_sequential_flow_two_tasks(self):
|
||||
flow = lf.Flow('flow-2').add(
|
||||
@ -124,8 +124,8 @@ class EngineLinearFlowTest(utils.EngineTestBase):
|
||||
utils.SaveOrderTask(self.values, name='task2')
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(self.values, ['task1', 'task2'])
|
||||
self.assertEquals(len(flow), 2)
|
||||
self.assertEqual(self.values, ['task1', 'task2'])
|
||||
self.assertEqual(len(flow), 2)
|
||||
|
||||
def test_revert_removes_data(self):
|
||||
flow = lf.Flow('revert-removes').add(
|
||||
@ -136,7 +136,7 @@ class EngineLinearFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {})
|
||||
self.assertEqual(engine.storage.fetch_all(), {})
|
||||
|
||||
def test_sequential_flow_nested_blocks(self):
|
||||
flow = lf.Flow('nested-1').add(
|
||||
@ -146,7 +146,7 @@ class EngineLinearFlowTest(utils.EngineTestBase):
|
||||
)
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(self.values, ['task1', 'task2'])
|
||||
self.assertEqual(self.values, ['task1', 'task2'])
|
||||
|
||||
def test_revert_exception_is_reraised(self):
|
||||
flow = lf.Flow('revert-1').add(
|
||||
@ -165,7 +165,7 @@ class EngineLinearFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine.run()
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
self.values,
|
||||
['fail reverted(Failure: RuntimeError: Woot!)'])
|
||||
|
||||
@ -180,7 +180,7 @@ class EngineLinearFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine.run()
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
self.values,
|
||||
['task1', 'task2',
|
||||
'fail reverted(Failure: RuntimeError: Woot!)',
|
||||
@ -194,7 +194,7 @@ class EngineParallelFlowTest(utils.EngineTestBase):
|
||||
utils.SaveOrderTask(self.values, name='task1', sleep=0.01)
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(self.values, ['task1'])
|
||||
self.assertEqual(self.values, ['task1'])
|
||||
|
||||
def test_parallel_flow_two_tasks(self):
|
||||
flow = uf.Flow('p-2').add(
|
||||
@ -204,8 +204,8 @@ class EngineParallelFlowTest(utils.EngineTestBase):
|
||||
self._make_engine(flow).run()
|
||||
|
||||
result = set(self.values)
|
||||
self.assertEquals(result, set(['task1', 'task2']))
|
||||
self.assertEquals(len(flow), 2)
|
||||
self.assertEqual(result, set(['task1', 'task2']))
|
||||
self.assertEqual(len(flow), 2)
|
||||
|
||||
def test_parallel_revert_common(self):
|
||||
flow = uf.Flow('p-r-3').add(
|
||||
@ -252,9 +252,9 @@ class EngineParallelFlowTest(utils.EngineTestBase):
|
||||
|
||||
engine = self._make_engine(flow, fd)
|
||||
engine.run()
|
||||
self.assertEquals(self.values, ['task2'])
|
||||
self.assertEquals(engine.storage.fetch_all(),
|
||||
{'x1': 17, 'x2': 5})
|
||||
self.assertEqual(self.values, ['task2'])
|
||||
self.assertEqual(engine.storage.fetch_all(),
|
||||
{'x1': 17, 'x2': 5})
|
||||
|
||||
def test_parallel_revert_specific(self):
|
||||
flow = uf.Flow('p-r-r').add(
|
||||
@ -284,7 +284,7 @@ class EngineParallelFlowTest(utils.EngineTestBase):
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Gotcha'):
|
||||
engine.run()
|
||||
result = set(self.values)
|
||||
self.assertEquals(result, set(['task1']))
|
||||
self.assertEqual(result, set(['task1']))
|
||||
|
||||
def test_nested_parallel_revert_exception_is_reraised(self):
|
||||
flow = uf.Flow('p-root').add(
|
||||
@ -426,7 +426,7 @@ class EngineGraphFlowTest(utils.EngineTestBase):
|
||||
utils.SaveOrderTask(self.values, name='task1')
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(self.values, ['task1'])
|
||||
self.assertEqual(self.values, ['task1'])
|
||||
|
||||
def test_graph_flow_two_independent_tasks(self):
|
||||
flow = gf.Flow('g-2').add(
|
||||
@ -434,8 +434,8 @@ class EngineGraphFlowTest(utils.EngineTestBase):
|
||||
utils.SaveOrderTask(self.values, name='task2')
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(set(self.values), set(['task1', 'task2']))
|
||||
self.assertEquals(len(flow), 2)
|
||||
self.assertEqual(set(self.values), set(['task1', 'task2']))
|
||||
self.assertEqual(len(flow), 2)
|
||||
|
||||
def test_graph_flow_two_tasks(self):
|
||||
flow = gf.Flow('g-1-1').add(
|
||||
@ -443,7 +443,7 @@ class EngineGraphFlowTest(utils.EngineTestBase):
|
||||
utils.SaveOrderTask(self.values, name='task1', provides='a')
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(self.values, ['task1', 'task2'])
|
||||
self.assertEqual(self.values, ['task1', 'task2'])
|
||||
|
||||
def test_graph_flow_four_tasks_added_separately(self):
|
||||
flow = (gf.Flow('g-4')
|
||||
@ -457,7 +457,7 @@ class EngineGraphFlowTest(utils.EngineTestBase):
|
||||
provides='a'))
|
||||
)
|
||||
self._make_engine(flow).run()
|
||||
self.assertEquals(self.values, ['task1', 'task2', 'task3', 'task4'])
|
||||
self.assertEqual(self.values, ['task1', 'task2', 'task3', 'task4'])
|
||||
|
||||
def test_graph_flow_four_tasks_revert(self):
|
||||
flow = gf.Flow('g-4-failing').add(
|
||||
@ -472,12 +472,12 @@ class EngineGraphFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine.run()
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
self.values,
|
||||
['task1', 'task2',
|
||||
'task3 reverted(Failure: RuntimeError: Woot!)',
|
||||
'task2 reverted(5)', 'task1 reverted(5)'])
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.REVERTED)
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.REVERTED)
|
||||
|
||||
def test_graph_flow_four_tasks_revert_failure(self):
|
||||
flow = gf.Flow('g-3-nasty').add(
|
||||
@ -488,7 +488,7 @@ class EngineGraphFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Gotcha'):
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.FAILURE)
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.FAILURE)
|
||||
|
||||
def test_graph_flow_with_multireturn_and_multiargs_tasks(self):
|
||||
flow = gf.Flow('g-3-multi').add(
|
||||
@ -501,7 +501,7 @@ class EngineGraphFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'x': 30})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {
|
||||
self.assertEqual(engine.storage.fetch_all(), {
|
||||
'a': 1,
|
||||
'b': 3,
|
||||
'c': 5,
|
||||
|
@ -29,20 +29,20 @@ class ArgumentsPassingTest(utils.EngineTestBase):
|
||||
flow = utils.TaskOneReturn(name='task1', provides='first_data')
|
||||
engine = self._make_engine(flow)
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {'first_data': 1})
|
||||
self.assertEqual(engine.storage.fetch_all(), {'first_data': 1})
|
||||
|
||||
def test_save_all_in_one(self):
|
||||
flow = utils.TaskMultiReturn(provides='all_data')
|
||||
engine = self._make_engine(flow)
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(),
|
||||
{'all_data': (1, 3, 5)})
|
||||
self.assertEqual(engine.storage.fetch_all(),
|
||||
{'all_data': (1, 3, 5)})
|
||||
|
||||
def test_save_several_values(self):
|
||||
flow = utils.TaskMultiReturn(provides=('badger', 'mushroom', 'snake'))
|
||||
engine = self._make_engine(flow)
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {
|
||||
self.assertEqual(engine.storage.fetch_all(), {
|
||||
'badger': 1,
|
||||
'mushroom': 3,
|
||||
'snake': 5
|
||||
@ -54,7 +54,7 @@ class ArgumentsPassingTest(utils.EngineTestBase):
|
||||
'snake']))
|
||||
engine = self._make_engine(flow)
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {
|
||||
self.assertEqual(engine.storage.fetch_all(), {
|
||||
'badger': 0,
|
||||
'mushroom': 1,
|
||||
'snake': 2,
|
||||
@ -69,7 +69,7 @@ class ArgumentsPassingTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'x': 1, 'y': 4, 'z': 9, 'a': 17})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {
|
||||
self.assertEqual(engine.storage.fetch_all(), {
|
||||
'x': 1, 'y': 4, 'z': 9, 'a': 17,
|
||||
'result': 14,
|
||||
})
|
||||
@ -87,7 +87,7 @@ class ArgumentsPassingTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'x': 1, 'y': 4, 'z': 9, 'a': 17})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {
|
||||
self.assertEqual(engine.storage.fetch_all(), {
|
||||
'x': 1, 'y': 4, 'z': 9, 'a': 17,
|
||||
'result': 30,
|
||||
})
|
||||
@ -100,7 +100,7 @@ class ArgumentsPassingTest(utils.EngineTestBase):
|
||||
'a': 1, 'b': 2, 'c': 3, 'x': 4, 'y': 5, 'z': 6
|
||||
})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.fetch_all(), {
|
||||
self.assertEqual(engine.storage.fetch_all(), {
|
||||
'a': 1, 'b': 2, 'c': 3, 'x': 4, 'y': 5, 'z': 6,
|
||||
'result': 6,
|
||||
})
|
||||
|
@ -58,7 +58,7 @@ class FlowFromDetailTestCase(test.TestCase):
|
||||
return_value=lambda: 'RESULT') as mock_import:
|
||||
result = taskflow.engines.flow_from_detail(flow_detail)
|
||||
mock_import.assert_called_onec_with(name)
|
||||
self.assertEquals(result, 'RESULT')
|
||||
self.assertEqual(result, 'RESULT')
|
||||
|
||||
def test_factory_with_arg(self):
|
||||
name = 'some.test.factory'
|
||||
@ -69,7 +69,7 @@ class FlowFromDetailTestCase(test.TestCase):
|
||||
return_value=lambda x: 'RESULT %s' % x) as mock_import:
|
||||
result = taskflow.engines.flow_from_detail(flow_detail)
|
||||
mock_import.assert_called_onec_with(name)
|
||||
self.assertEquals(result, 'RESULT foo')
|
||||
self.assertEqual(result, 'RESULT foo')
|
||||
|
||||
|
||||
def my_flow_factory(task_name):
|
||||
@ -91,8 +91,8 @@ class LoadFromFactoryTestCase(test.TestCase):
|
||||
self.assertIsInstance(engine._flow, test_utils.DummyTask)
|
||||
|
||||
fd = engine.storage._flowdetail
|
||||
self.assertEquals(fd.name, 'test1')
|
||||
self.assertEquals(fd.meta.get('factory'), {
|
||||
self.assertEqual(fd.name, 'test1')
|
||||
self.assertEqual(fd.meta.get('factory'), {
|
||||
'name': '%s.my_flow_factory' % __name__,
|
||||
'args': [],
|
||||
'kwargs': {'task_name': 'test1'},
|
||||
@ -105,8 +105,8 @@ class LoadFromFactoryTestCase(test.TestCase):
|
||||
self.assertIsInstance(engine._flow, test_utils.DummyTask)
|
||||
|
||||
fd = engine.storage._flowdetail
|
||||
self.assertEquals(fd.name, 'test1')
|
||||
self.assertEquals(fd.meta.get('factory'), {
|
||||
self.assertEqual(fd.name, 'test1')
|
||||
self.assertEqual(fd.meta.get('factory'), {
|
||||
'name': factory_name,
|
||||
'args': [],
|
||||
'kwargs': {'task_name': 'test1'},
|
||||
|
@ -49,13 +49,13 @@ class FlattenTest(test.TestCase):
|
||||
flo.add(sflo)
|
||||
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(4, len(g))
|
||||
self.assertEqual(4, len(g))
|
||||
|
||||
order = nx.topological_sort(g)
|
||||
self.assertEquals([a, b, c, d], order)
|
||||
self.assertEqual([a, b, c, d], order)
|
||||
self.assertTrue(g.has_edge(c, d))
|
||||
self.assertEquals([d], list(g_utils.get_no_successors(g)))
|
||||
self.assertEquals([a], list(g_utils.get_no_predecessors(g)))
|
||||
self.assertEqual([d], list(g_utils.get_no_successors(g)))
|
||||
self.assertEqual([a], list(g_utils.get_no_predecessors(g)))
|
||||
|
||||
def test_invalid_flatten(self):
|
||||
a, b, c = _make_many(3)
|
||||
@ -69,12 +69,12 @@ class FlattenTest(test.TestCase):
|
||||
flo = uf.Flow("test")
|
||||
flo.add(a, b, c, d)
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(4, len(g))
|
||||
self.assertEquals(0, g.number_of_edges())
|
||||
self.assertEquals(set([a, b, c, d]),
|
||||
set(g_utils.get_no_successors(g)))
|
||||
self.assertEquals(set([a, b, c, d]),
|
||||
set(g_utils.get_no_predecessors(g)))
|
||||
self.assertEqual(4, len(g))
|
||||
self.assertEqual(0, g.number_of_edges())
|
||||
self.assertEqual(set([a, b, c, d]),
|
||||
set(g_utils.get_no_successors(g)))
|
||||
self.assertEqual(set([a, b, c, d]),
|
||||
set(g_utils.get_no_predecessors(g)))
|
||||
|
||||
def test_linear_nested_flatten(self):
|
||||
a, b, c, d = _make_many(4)
|
||||
@ -84,14 +84,14 @@ class FlattenTest(test.TestCase):
|
||||
flo2.add(c, d)
|
||||
flo.add(flo2)
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(4, len(g))
|
||||
self.assertEqual(4, len(g))
|
||||
|
||||
lb = g.subgraph([a, b])
|
||||
self.assertTrue(lb.has_edge(a, b))
|
||||
self.assertFalse(lb.has_edge(b, a))
|
||||
|
||||
ub = g.subgraph([c, d])
|
||||
self.assertEquals(0, ub.number_of_edges())
|
||||
self.assertEqual(0, ub.number_of_edges())
|
||||
|
||||
# This ensures that c and d do not start executing until after b.
|
||||
self.assertTrue(g.has_edge(b, c))
|
||||
@ -106,7 +106,7 @@ class FlattenTest(test.TestCase):
|
||||
flo.add(flo2)
|
||||
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(4, len(g))
|
||||
self.assertEqual(4, len(g))
|
||||
for n in [a, b]:
|
||||
self.assertFalse(g.has_edge(n, c))
|
||||
self.assertFalse(g.has_edge(n, d))
|
||||
@ -114,9 +114,9 @@ class FlattenTest(test.TestCase):
|
||||
self.assertFalse(g.has_edge(d, c))
|
||||
|
||||
ub = g.subgraph([a, b])
|
||||
self.assertEquals(0, ub.number_of_edges())
|
||||
self.assertEqual(0, ub.number_of_edges())
|
||||
lb = g.subgraph([c, d])
|
||||
self.assertEquals(1, lb.number_of_edges())
|
||||
self.assertEqual(1, lb.number_of_edges())
|
||||
|
||||
def test_graph_flatten(self):
|
||||
a, b, c, d = _make_many(4)
|
||||
@ -124,8 +124,8 @@ class FlattenTest(test.TestCase):
|
||||
flo.add(a, b, c, d)
|
||||
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(4, len(g))
|
||||
self.assertEquals(0, g.number_of_edges())
|
||||
self.assertEqual(4, len(g))
|
||||
self.assertEqual(0, g.number_of_edges())
|
||||
|
||||
def test_graph_flatten_nested(self):
|
||||
a, b, c, d, e, f, g = _make_many(7)
|
||||
@ -137,8 +137,8 @@ class FlattenTest(test.TestCase):
|
||||
flo.add(flo2)
|
||||
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(7, len(g))
|
||||
self.assertEquals(2, g.number_of_edges())
|
||||
self.assertEqual(7, len(g))
|
||||
self.assertEqual(2, g.number_of_edges())
|
||||
|
||||
def test_graph_flatten_nested_graph(self):
|
||||
a, b, c, d, e, f, g = _make_many(7)
|
||||
@ -150,8 +150,8 @@ class FlattenTest(test.TestCase):
|
||||
flo.add(flo2)
|
||||
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(7, len(g))
|
||||
self.assertEquals(0, g.number_of_edges())
|
||||
self.assertEqual(7, len(g))
|
||||
self.assertEqual(0, g.number_of_edges())
|
||||
|
||||
def test_graph_flatten_links(self):
|
||||
a, b, c, d = _make_many(4)
|
||||
@ -162,12 +162,12 @@ class FlattenTest(test.TestCase):
|
||||
flo.link(c, d)
|
||||
|
||||
g = f_utils.flatten(flo)
|
||||
self.assertEquals(4, len(g))
|
||||
self.assertEquals(3, g.number_of_edges())
|
||||
self.assertEquals(set([a]),
|
||||
set(g_utils.get_no_predecessors(g)))
|
||||
self.assertEquals(set([d]),
|
||||
set(g_utils.get_no_successors(g)))
|
||||
self.assertEqual(4, len(g))
|
||||
self.assertEqual(3, g.number_of_edges())
|
||||
self.assertEqual(set([a]),
|
||||
set(g_utils.get_no_predecessors(g)))
|
||||
self.assertEqual(set([d]),
|
||||
set(g_utils.get_no_successors(g)))
|
||||
|
||||
def test_flatten_checks_for_dups(self):
|
||||
flo = gf.Flow("test").add(
|
||||
|
@ -29,61 +29,61 @@ class FlowDependenciesTest(test.TestCase):
|
||||
|
||||
def test_task_without_dependencies(self):
|
||||
flow = utils.TaskNoRequiresNoReturns()
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_task_requires_default_values(self):
|
||||
flow = utils.TaskMultiArg()
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_task_requires_rebinded_mapped(self):
|
||||
flow = utils.TaskMultiArg(rebind={'x': 'a', 'y': 'b', 'z': 'c'})
|
||||
self.assertEquals(flow.requires, set(['a', 'b', 'c']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['a', 'b', 'c']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_task_requires_additional_values(self):
|
||||
flow = utils.TaskMultiArg(requires=['a', 'b'])
|
||||
self.assertEquals(flow.requires, set(['a', 'b', 'x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['a', 'b', 'x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_task_provides_values(self):
|
||||
flow = utils.TaskMultiReturn(provides=['a', 'b', 'c'])
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set(['a', 'b', 'c']))
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set(['a', 'b', 'c']))
|
||||
|
||||
def test_task_provides_and_requires_values(self):
|
||||
flow = utils.TaskMultiArgMultiReturn(provides=['a', 'b', 'c'])
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set(['a', 'b', 'c']))
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set(['a', 'b', 'c']))
|
||||
|
||||
def test_linear_flow_without_dependencies(self):
|
||||
flow = lf.Flow('lf').add(
|
||||
utils.TaskNoRequiresNoReturns('task1'),
|
||||
utils.TaskNoRequiresNoReturns('task2'))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_linear_flow_reuires_values(self):
|
||||
flow = lf.Flow('lf').add(
|
||||
utils.TaskOneArg('task1'),
|
||||
utils.TaskMultiArg('task2'))
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_linear_flow_reuires_rebind_values(self):
|
||||
flow = lf.Flow('lf').add(
|
||||
utils.TaskOneArg('task1', rebind=['q']),
|
||||
utils.TaskMultiArg('task2'))
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z', 'q']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z', 'q']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_linear_flow_provides_values(self):
|
||||
flow = lf.Flow('lf').add(
|
||||
utils.TaskOneReturn('task1', provides='x'),
|
||||
utils.TaskMultiReturn('task2', provides=['a', 'b', 'c']))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set(['x', 'a', 'b', 'c']))
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set(['x', 'a', 'b', 'c']))
|
||||
|
||||
def test_linear_flow_provides_out_of_order(self):
|
||||
with self.assertRaises(exceptions.InvariantViolationException):
|
||||
@ -95,8 +95,8 @@ class FlowDependenciesTest(test.TestCase):
|
||||
flow = lf.Flow('lf').add(
|
||||
utils.TaskOneReturn('task1', provides='x'),
|
||||
utils.TaskOneArg('task2'))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set(['x']))
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set(['x']))
|
||||
|
||||
def test_linear_flow_multi_provides_and_requires_values(self):
|
||||
flow = lf.Flow('lf').add(
|
||||
@ -105,8 +105,8 @@ class FlowDependenciesTest(test.TestCase):
|
||||
provides=['x', 'y', 'q']),
|
||||
utils.TaskMultiArgMultiReturn('task2',
|
||||
provides=['i', 'j', 'k']))
|
||||
self.assertEquals(flow.requires, set(['a', 'b', 'c', 'z']))
|
||||
self.assertEquals(flow.provides, set(['x', 'y', 'q', 'i', 'j', 'k']))
|
||||
self.assertEqual(flow.requires, set(['a', 'b', 'c', 'z']))
|
||||
self.assertEqual(flow.provides, set(['x', 'y', 'q', 'i', 'j', 'k']))
|
||||
|
||||
def test_linear_flow_self_requires(self):
|
||||
flow = lf.Flow('uf')
|
||||
@ -117,8 +117,8 @@ class FlowDependenciesTest(test.TestCase):
|
||||
flow = uf.Flow('uf').add(
|
||||
utils.TaskNoRequiresNoReturns('task1'),
|
||||
utils.TaskNoRequiresNoReturns('task2'))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_unordered_flow_self_requires(self):
|
||||
flow = uf.Flow('uf')
|
||||
@ -129,22 +129,22 @@ class FlowDependenciesTest(test.TestCase):
|
||||
flow = uf.Flow('uf').add(
|
||||
utils.TaskOneArg('task1'),
|
||||
utils.TaskMultiArg('task2'))
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_unordered_flow_reuires_rebind_values(self):
|
||||
flow = uf.Flow('uf').add(
|
||||
utils.TaskOneArg('task1', rebind=['q']),
|
||||
utils.TaskMultiArg('task2'))
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z', 'q']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z', 'q']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_unordered_flow_provides_values(self):
|
||||
flow = uf.Flow('uf').add(
|
||||
utils.TaskOneReturn('task1', provides='x'),
|
||||
utils.TaskMultiReturn('task2', provides=['a', 'b', 'c']))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set(['x', 'a', 'b', 'c']))
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set(['x', 'a', 'b', 'c']))
|
||||
|
||||
def test_unordered_flow_provides_required_values(self):
|
||||
with self.assertRaises(exceptions.InvariantViolationException):
|
||||
@ -171,8 +171,8 @@ class FlowDependenciesTest(test.TestCase):
|
||||
provides=['d', 'e', 'f']),
|
||||
utils.TaskMultiArgMultiReturn('task2',
|
||||
provides=['i', 'j', 'k']))
|
||||
self.assertEquals(flow.requires, set(['a', 'b', 'c', 'x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set(['d', 'e', 'f', 'i', 'j', 'k']))
|
||||
self.assertEqual(flow.requires, set(['a', 'b', 'c', 'x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set(['d', 'e', 'f', 'i', 'j', 'k']))
|
||||
|
||||
def test_nested_flows_requirements(self):
|
||||
flow = uf.Flow('uf').add(
|
||||
@ -185,15 +185,15 @@ class FlowDependenciesTest(test.TestCase):
|
||||
rebind=['b'], provides=['z']),
|
||||
utils.TaskOneArgOneReturn('task4', rebind=['c'],
|
||||
provides=['q'])))
|
||||
self.assertEquals(flow.requires, set(['a', 'b', 'c']))
|
||||
self.assertEquals(flow.provides, set(['x', 'y', 'z', 'q']))
|
||||
self.assertEqual(flow.requires, set(['a', 'b', 'c']))
|
||||
self.assertEqual(flow.provides, set(['x', 'y', 'z', 'q']))
|
||||
|
||||
def test_graph_flow_without_dependencies(self):
|
||||
flow = gf.Flow('gf').add(
|
||||
utils.TaskNoRequiresNoReturns('task1'),
|
||||
utils.TaskNoRequiresNoReturns('task2'))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_graph_flow_self_requires(self):
|
||||
with self.assertRaisesRegexp(exceptions.DependencyFailure, '^No path'):
|
||||
@ -204,29 +204,29 @@ class FlowDependenciesTest(test.TestCase):
|
||||
flow = gf.Flow('gf').add(
|
||||
utils.TaskOneArg('task1'),
|
||||
utils.TaskMultiArg('task2'))
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_graph_flow_reuires_rebind_values(self):
|
||||
flow = gf.Flow('gf').add(
|
||||
utils.TaskOneArg('task1', rebind=['q']),
|
||||
utils.TaskMultiArg('task2'))
|
||||
self.assertEquals(flow.requires, set(['x', 'y', 'z', 'q']))
|
||||
self.assertEquals(flow.provides, set())
|
||||
self.assertEqual(flow.requires, set(['x', 'y', 'z', 'q']))
|
||||
self.assertEqual(flow.provides, set())
|
||||
|
||||
def test_graph_flow_provides_values(self):
|
||||
flow = gf.Flow('gf').add(
|
||||
utils.TaskOneReturn('task1', provides='x'),
|
||||
utils.TaskMultiReturn('task2', provides=['a', 'b', 'c']))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set(['x', 'a', 'b', 'c']))
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set(['x', 'a', 'b', 'c']))
|
||||
|
||||
def test_graph_flow_provides_required_values(self):
|
||||
flow = gf.Flow('gf').add(
|
||||
utils.TaskOneReturn('task1', provides='x'),
|
||||
utils.TaskOneArg('task2'))
|
||||
self.assertEquals(flow.requires, set())
|
||||
self.assertEquals(flow.provides, set(['x']))
|
||||
self.assertEqual(flow.requires, set())
|
||||
self.assertEqual(flow.provides, set(['x']))
|
||||
|
||||
def test_graph_flow_provides_provided_value_other_call(self):
|
||||
flow = gf.Flow('gf')
|
||||
@ -241,8 +241,8 @@ class FlowDependenciesTest(test.TestCase):
|
||||
provides=['d', 'e', 'f']),
|
||||
utils.TaskMultiArgMultiReturn('task2',
|
||||
provides=['i', 'j', 'k']))
|
||||
self.assertEquals(flow.requires, set(['a', 'b', 'c', 'x', 'y', 'z']))
|
||||
self.assertEquals(flow.provides, set(['d', 'e', 'f', 'i', 'j', 'k']))
|
||||
self.assertEqual(flow.requires, set(['a', 'b', 'c', 'x', 'y', 'z']))
|
||||
self.assertEqual(flow.provides, set(['d', 'e', 'f', 'i', 'j', 'k']))
|
||||
|
||||
def test_graph_cyclic_dependency(self):
|
||||
with self.assertRaisesRegexp(exceptions.DependencyFailure, '^No path'):
|
||||
|
@ -47,11 +47,11 @@ class FunctorTaskTest(test.TestCase):
|
||||
|
||||
def test_simple(self):
|
||||
task = base.FunctorTask(add)
|
||||
self.assertEquals(task.name, __name__ + '.add')
|
||||
self.assertEqual(task.name, __name__ + '.add')
|
||||
|
||||
def test_other_name(self):
|
||||
task = base.FunctorTask(add, name='my task')
|
||||
self.assertEquals(task.name, 'my task')
|
||||
self.assertEqual(task.name, 'my task')
|
||||
|
||||
def test_it_runs(self):
|
||||
values = []
|
||||
@ -65,4 +65,4 @@ class FunctorTaskTest(test.TestCase):
|
||||
)
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
taskflow.engines.run(flow)
|
||||
self.assertEquals(values, ['one', 'fail', 'revert one'])
|
||||
self.assertEqual(values, ['one', 'fail', 'revert one'])
|
||||
|
@ -58,9 +58,9 @@ class GraphFlowTest(test.TestCase):
|
||||
wf.add(test_1, test_2, test_3)
|
||||
self.assertTrue(wf.graph.has_edge(test_1, test_2))
|
||||
self.assertTrue(wf.graph.has_edge(test_2, test_3))
|
||||
self.assertEquals(3, len(wf.graph))
|
||||
self.assertEquals([test_1], list(gu.get_no_predecessors(wf.graph)))
|
||||
self.assertEquals([test_3], list(gu.get_no_successors(wf.graph)))
|
||||
self.assertEqual(3, len(wf.graph))
|
||||
self.assertEqual([test_1], list(gu.get_no_predecessors(wf.graph)))
|
||||
self.assertEqual([test_3], list(gu.get_no_successors(wf.graph)))
|
||||
|
||||
def test_basic_edge_reasons(self):
|
||||
wf = gw.Flow("the-test-action")
|
||||
@ -76,7 +76,7 @@ class GraphFlowTest(test.TestCase):
|
||||
edge_attrs = gu.get_edge_attrs(wf.graph, test_1, test_2)
|
||||
self.assertTrue(len(edge_attrs) > 0)
|
||||
self.assertIn('reasons', edge_attrs)
|
||||
self.assertEquals(set(['a', 'b']), edge_attrs['reasons'])
|
||||
self.assertEqual(set(['a', 'b']), edge_attrs['reasons'])
|
||||
|
||||
# 2 -> 1 should not be linked, and therefore have no attrs
|
||||
no_edge_attrs = gu.get_edge_attrs(wf.graph, test_2, test_1)
|
||||
@ -110,7 +110,7 @@ class GraphFlowTest(test.TestCase):
|
||||
wf.add(test_1, test_2)
|
||||
wf.link(test_1, test_2)
|
||||
g = fu.flatten(wf)
|
||||
self.assertEquals(2, len(g))
|
||||
self.assertEqual(2, len(g))
|
||||
edge_attrs = gu.get_edge_attrs(g, test_1, test_2)
|
||||
self.assertTrue(edge_attrs.get('manual'))
|
||||
self.assertTrue(edge_attrs.get('flatten'))
|
||||
|
@ -40,8 +40,8 @@ class GreenExecutorTest(test.TestCase):
|
||||
for f in self.make_funcs(called, 2):
|
||||
e.submit(f)
|
||||
|
||||
self.assertEquals(1, called[0])
|
||||
self.assertEquals(1, called[1])
|
||||
self.assertEqual(1, called[0])
|
||||
self.assertEqual(1, called[1])
|
||||
|
||||
def test_no_construction(self):
|
||||
self.assertRaises(AssertionError, eu.GreenExecutor, 0)
|
||||
@ -59,7 +59,7 @@ class GreenExecutorTest(test.TestCase):
|
||||
f = e.submit(funcs[0])
|
||||
f.add_done_callback(call_back)
|
||||
|
||||
self.assertEquals(2, len(called))
|
||||
self.assertEqual(2, len(called))
|
||||
|
||||
def test_exception_transfer(self):
|
||||
|
||||
@ -82,10 +82,10 @@ class GreenExecutorTest(test.TestCase):
|
||||
for i in range(0, create_am):
|
||||
futures.append(e.submit(functools.partial(return_given, i)))
|
||||
|
||||
self.assertEquals(create_am, len(futures))
|
||||
self.assertEqual(create_am, len(futures))
|
||||
for i in range(0, create_am):
|
||||
result = futures[i].result()
|
||||
self.assertEquals(i, result)
|
||||
self.assertEqual(i, result)
|
||||
|
||||
def test_func_cancellation(self):
|
||||
called = collections.defaultdict(int)
|
||||
@ -103,7 +103,7 @@ class GreenExecutorTest(test.TestCase):
|
||||
self.assertFalse(f.running())
|
||||
f.cancel()
|
||||
|
||||
self.assertEquals(0, len(called))
|
||||
self.assertEqual(0, len(called))
|
||||
for f in futures:
|
||||
self.assertTrue(f.cancelled())
|
||||
self.assertTrue(f.done())
|
||||
|
@ -72,9 +72,9 @@ class TestProgress(test.TestCase):
|
||||
flo.add(t)
|
||||
e = self._make_engine(flo)
|
||||
e.run()
|
||||
self.assertEquals(ev_count + 1, len(fired_events))
|
||||
self.assertEquals(1.0, fired_events[-1])
|
||||
self.assertEquals(0.0, fired_events[0])
|
||||
self.assertEqual(ev_count + 1, len(fired_events))
|
||||
self.assertEqual(1.0, fired_events[-1])
|
||||
self.assertEqual(0.0, fired_events[0])
|
||||
|
||||
def test_no_segments_progress(self):
|
||||
fired_events = []
|
||||
@ -89,9 +89,9 @@ class TestProgress(test.TestCase):
|
||||
e = self._make_engine(flo)
|
||||
e.run()
|
||||
# 0.0 and 1.0 should be automatically fired
|
||||
self.assertEquals(2, len(fired_events))
|
||||
self.assertEquals(1.0, fired_events[-1])
|
||||
self.assertEquals(0.0, fired_events[0])
|
||||
self.assertEqual(2, len(fired_events))
|
||||
self.assertEqual(1.0, fired_events[-1])
|
||||
self.assertEqual(0.0, fired_events[0])
|
||||
|
||||
def test_storage_progress(self):
|
||||
with contextlib.closing(impl_memory.MemoryBackend({})) as be:
|
||||
@ -102,9 +102,9 @@ class TestProgress(test.TestCase):
|
||||
e.run()
|
||||
t_uuid = e.storage.get_uuid_by_name("test")
|
||||
end_progress = e.storage.get_task_progress(t_uuid)
|
||||
self.assertEquals(1.0, end_progress)
|
||||
self.assertEqual(1.0, end_progress)
|
||||
td = fd.find(t_uuid)
|
||||
self.assertEquals(1.0, td.meta['progress'])
|
||||
self.assertEqual(1.0, td.meta['progress'])
|
||||
self.assertFalse(td.meta['progress_details'])
|
||||
|
||||
def test_storage_progress_detail(self):
|
||||
@ -113,10 +113,10 @@ class TestProgress(test.TestCase):
|
||||
e.run()
|
||||
t_uuid = e.storage.get_uuid_by_name("test")
|
||||
end_progress = e.storage.get_task_progress(t_uuid)
|
||||
self.assertEquals(1.0, end_progress)
|
||||
self.assertEqual(1.0, end_progress)
|
||||
end_details = e.storage.get_task_progress_details(t_uuid)
|
||||
self.assertEquals(end_details.get('at_progress'), 0.5)
|
||||
self.assertEquals(end_details.get('details'), {
|
||||
self.assertEqual(end_details.get('at_progress'), 0.5)
|
||||
self.assertEqual(end_details.get('details'), {
|
||||
'test': 'test data',
|
||||
'foo': 'bar'
|
||||
})
|
||||
@ -138,8 +138,8 @@ class TestProgress(test.TestCase):
|
||||
|
||||
t_uuid = e.storage.get_uuid_by_name("test")
|
||||
end_progress = e.storage.get_task_progress(t_uuid)
|
||||
self.assertEquals(1.0, end_progress)
|
||||
self.assertEqual(1.0, end_progress)
|
||||
td = fd.find(t_uuid)
|
||||
self.assertEquals(1.0, td.meta['progress'])
|
||||
self.assertEqual(1.0, td.meta['progress'])
|
||||
self.assertFalse(td.meta['progress_details'])
|
||||
self.assertEquals(6, len(fired_events))
|
||||
self.assertEqual(6, len(fired_events))
|
||||
|
@ -48,18 +48,18 @@ class StorageTest(test.TestCase):
|
||||
_lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
|
||||
s = storage.Storage(flow_detail=flow_detail) # no backend
|
||||
s.add_task('42', 'my task')
|
||||
self.assertEquals(s.get_uuid_by_name('my task'), '42')
|
||||
self.assertEqual(s.get_uuid_by_name('my task'), '42')
|
||||
|
||||
def test_flow_name_and_uuid(self):
|
||||
fd = logbook.FlowDetail(name='test-fd', uuid='aaaa')
|
||||
s = storage.Storage(flow_detail=fd)
|
||||
self.assertEquals(s.flow_name, 'test-fd')
|
||||
self.assertEquals(s.flow_uuid, 'aaaa')
|
||||
self.assertEqual(s.flow_name, 'test-fd')
|
||||
self.assertEqual(s.flow_uuid, 'aaaa')
|
||||
|
||||
def test_add_task(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
self.assertEquals(s.get_task_state('42'), states.PENDING)
|
||||
self.assertEqual(s.get_task_state('42'), states.PENDING)
|
||||
|
||||
def test_add_task_fd(self):
|
||||
_lb, flow_detail = p_utils.temporary_flow_detail(self.backend)
|
||||
@ -67,33 +67,33 @@ class StorageTest(test.TestCase):
|
||||
s.add_task('42', 'my task', '3.11')
|
||||
td = flow_detail.find('42')
|
||||
self.assertIsNot(td, None)
|
||||
self.assertEquals(td.uuid, '42')
|
||||
self.assertEquals(td.name, 'my task')
|
||||
self.assertEquals(td.version, '3.11')
|
||||
self.assertEquals(td.state, states.PENDING)
|
||||
self.assertEqual(td.uuid, '42')
|
||||
self.assertEqual(td.name, 'my task')
|
||||
self.assertEqual(td.version, '3.11')
|
||||
self.assertEqual(td.state, states.PENDING)
|
||||
|
||||
def test_save_and_get(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
s.save('42', 5)
|
||||
self.assertEquals(s.get('42'), 5)
|
||||
self.assertEquals(s.fetch_all(), {})
|
||||
self.assertEquals(s.get_task_state('42'), states.SUCCESS)
|
||||
self.assertEqual(s.get('42'), 5)
|
||||
self.assertEqual(s.fetch_all(), {})
|
||||
self.assertEqual(s.get_task_state('42'), states.SUCCESS)
|
||||
|
||||
def test_save_and_get_other_state(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
s.save('42', 5, states.FAILURE)
|
||||
self.assertEquals(s.get('42'), 5)
|
||||
self.assertEquals(s.get_task_state('42'), states.FAILURE)
|
||||
self.assertEqual(s.get('42'), 5)
|
||||
self.assertEqual(s.get_task_state('42'), states.FAILURE)
|
||||
|
||||
def test_save_and_get_failure(self):
|
||||
fail = misc.Failure(exc_info=(RuntimeError, RuntimeError(), None))
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
s.save('42', fail, states.FAILURE)
|
||||
self.assertEquals(s.get('42'), fail)
|
||||
self.assertEquals(s.get_task_state('42'), states.FAILURE)
|
||||
self.assertEqual(s.get('42'), fail)
|
||||
self.assertEqual(s.get_task_state('42'), states.FAILURE)
|
||||
|
||||
def test_get_failure_from_reverted_task(self):
|
||||
fail = misc.Failure(exc_info=(RuntimeError, RuntimeError(), None))
|
||||
@ -102,10 +102,10 @@ class StorageTest(test.TestCase):
|
||||
s.save('42', fail, states.FAILURE)
|
||||
|
||||
s.set_task_state('42', states.REVERTING)
|
||||
self.assertEquals(s.get('42'), fail)
|
||||
self.assertEqual(s.get('42'), fail)
|
||||
|
||||
s.set_task_state('42', states.REVERTED)
|
||||
self.assertEquals(s.get('42'), fail)
|
||||
self.assertEqual(s.get('42'), fail)
|
||||
|
||||
def test_get_non_existing_var(self):
|
||||
s = self._get_storage()
|
||||
@ -118,14 +118,14 @@ class StorageTest(test.TestCase):
|
||||
s.add_task('42', 'my task')
|
||||
s.save('42', 5)
|
||||
s.reset('42')
|
||||
self.assertEquals(s.get_task_state('42'), states.PENDING)
|
||||
self.assertEqual(s.get_task_state('42'), states.PENDING)
|
||||
with self.assertRaises(exceptions.NotFound):
|
||||
s.get('42')
|
||||
|
||||
def test_reset_unknown_task(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
self.assertEquals(s.reset('42'), None)
|
||||
self.assertEqual(s.reset('42'), None)
|
||||
|
||||
def test_reset_tasks(self):
|
||||
s = self._get_storage()
|
||||
@ -136,10 +136,10 @@ class StorageTest(test.TestCase):
|
||||
|
||||
s.reset_tasks()
|
||||
|
||||
self.assertEquals(s.get_task_state('42'), states.PENDING)
|
||||
self.assertEqual(s.get_task_state('42'), states.PENDING)
|
||||
with self.assertRaises(exceptions.NotFound):
|
||||
s.get('42')
|
||||
self.assertEquals(s.get_task_state('43'), states.PENDING)
|
||||
self.assertEqual(s.get_task_state('43'), states.PENDING)
|
||||
with self.assertRaises(exceptions.NotFound):
|
||||
s.get('43')
|
||||
|
||||
@ -151,8 +151,8 @@ class StorageTest(test.TestCase):
|
||||
# so resetting tasks may break it if implemented incorrectly
|
||||
s.reset_tasks()
|
||||
|
||||
self.assertEquals(s.fetch('spam'), 'eggs')
|
||||
self.assertEquals(s.fetch_all(), {
|
||||
self.assertEqual(s.fetch('spam'), 'eggs')
|
||||
self.assertEqual(s.fetch_all(), {
|
||||
'foo': 'bar',
|
||||
'spam': 'eggs',
|
||||
})
|
||||
@ -163,8 +163,8 @@ class StorageTest(test.TestCase):
|
||||
name = 'my result'
|
||||
s.set_result_mapping('42', {name: None})
|
||||
s.save('42', 5)
|
||||
self.assertEquals(s.fetch(name), 5)
|
||||
self.assertEquals(s.fetch_all(), {name: 5})
|
||||
self.assertEqual(s.fetch(name), 5)
|
||||
self.assertEqual(s.fetch_all(), {name: 5})
|
||||
|
||||
def test_fetch_unknown_name(self):
|
||||
s = self._get_storage()
|
||||
@ -175,30 +175,30 @@ class StorageTest(test.TestCase):
|
||||
def test_default_task_progress(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
self.assertEquals(s.get_task_progress('42'), 0.0)
|
||||
self.assertEquals(s.get_task_progress_details('42'), None)
|
||||
self.assertEqual(s.get_task_progress('42'), 0.0)
|
||||
self.assertEqual(s.get_task_progress_details('42'), None)
|
||||
|
||||
def test_task_progress(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
|
||||
s.set_task_progress('42', 0.5, {'test_data': 11})
|
||||
self.assertEquals(s.get_task_progress('42'), 0.5)
|
||||
self.assertEquals(s.get_task_progress_details('42'), {
|
||||
self.assertEqual(s.get_task_progress('42'), 0.5)
|
||||
self.assertEqual(s.get_task_progress_details('42'), {
|
||||
'at_progress': 0.5,
|
||||
'details': {'test_data': 11}
|
||||
})
|
||||
|
||||
s.set_task_progress('42', 0.7, {'test_data': 17})
|
||||
self.assertEquals(s.get_task_progress('42'), 0.7)
|
||||
self.assertEquals(s.get_task_progress_details('42'), {
|
||||
self.assertEqual(s.get_task_progress('42'), 0.7)
|
||||
self.assertEqual(s.get_task_progress_details('42'), {
|
||||
'at_progress': 0.7,
|
||||
'details': {'test_data': 17}
|
||||
})
|
||||
|
||||
s.set_task_progress('42', 0.99)
|
||||
self.assertEquals(s.get_task_progress('42'), 0.99)
|
||||
self.assertEquals(s.get_task_progress_details('42'), {
|
||||
self.assertEqual(s.get_task_progress('42'), 0.99)
|
||||
self.assertEqual(s.get_task_progress_details('42'), {
|
||||
'at_progress': 0.7,
|
||||
'details': {'test_data': 17}
|
||||
})
|
||||
@ -208,8 +208,8 @@ class StorageTest(test.TestCase):
|
||||
s.add_task('42', 'my task')
|
||||
|
||||
s.set_task_progress('42', 0.8, {})
|
||||
self.assertEquals(s.get_task_progress('42'), 0.8)
|
||||
self.assertEquals(s.get_task_progress_details('42'), None)
|
||||
self.assertEqual(s.get_task_progress('42'), 0.8)
|
||||
self.assertEqual(s.get_task_progress_details('42'), None)
|
||||
|
||||
def test_fetch_result_not_ready(self):
|
||||
s = self._get_storage()
|
||||
@ -218,14 +218,14 @@ class StorageTest(test.TestCase):
|
||||
s.set_result_mapping('42', {name: None})
|
||||
with self.assertRaises(exceptions.NotFound):
|
||||
s.get(name)
|
||||
self.assertEquals(s.fetch_all(), {})
|
||||
self.assertEqual(s.fetch_all(), {})
|
||||
|
||||
def test_save_multiple_results(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
s.set_result_mapping('42', {'foo': 0, 'bar': 1, 'whole': None})
|
||||
s.save('42', ('spam', 'eggs'))
|
||||
self.assertEquals(s.fetch_all(), {
|
||||
self.assertEqual(s.fetch_all(), {
|
||||
'foo': 'spam',
|
||||
'bar': 'eggs',
|
||||
'whole': ('spam', 'eggs')
|
||||
@ -236,13 +236,13 @@ class StorageTest(test.TestCase):
|
||||
s.add_task('42', 'my task')
|
||||
s.set_result_mapping('42', None)
|
||||
s.save('42', 5)
|
||||
self.assertEquals(s.fetch_all(), {})
|
||||
self.assertEqual(s.fetch_all(), {})
|
||||
|
||||
def test_inject(self):
|
||||
s = self._get_storage()
|
||||
s.inject({'foo': 'bar', 'spam': 'eggs'})
|
||||
self.assertEquals(s.fetch('spam'), 'eggs')
|
||||
self.assertEquals(s.fetch_all(), {
|
||||
self.assertEqual(s.fetch('spam'), 'eggs')
|
||||
self.assertEqual(s.fetch_all(), {
|
||||
'foo': 'bar',
|
||||
'spam': 'eggs',
|
||||
})
|
||||
@ -250,9 +250,9 @@ class StorageTest(test.TestCase):
|
||||
def test_inject_twice(self):
|
||||
s = self._get_storage()
|
||||
s.inject({'foo': 'bar'})
|
||||
self.assertEquals(s.fetch_all(), {'foo': 'bar'})
|
||||
self.assertEqual(s.fetch_all(), {'foo': 'bar'})
|
||||
s.inject({'spam': 'eggs'})
|
||||
self.assertEquals(s.fetch_all(), {
|
||||
self.assertEqual(s.fetch_all(), {
|
||||
'foo': 'bar',
|
||||
'spam': 'eggs',
|
||||
})
|
||||
@ -261,7 +261,7 @@ class StorageTest(test.TestCase):
|
||||
s = self._get_storage()
|
||||
s.inject({'foo': 'bar', 'spam': 'eggs'})
|
||||
# verify it's there
|
||||
self.assertEquals(s.fetch_all(), {
|
||||
self.assertEqual(s.fetch_all(), {
|
||||
'foo': 'bar',
|
||||
'spam': 'eggs',
|
||||
})
|
||||
@ -269,7 +269,7 @@ class StorageTest(test.TestCase):
|
||||
# storage from same flow details
|
||||
s2 = storage.Storage(s._flowdetail, backend=self.backend)
|
||||
# injected data should still be there:
|
||||
self.assertEquals(s2.fetch_all(), {
|
||||
self.assertEqual(s2.fetch_all(), {
|
||||
'foo': 'bar',
|
||||
'spam': 'eggs',
|
||||
})
|
||||
@ -277,8 +277,8 @@ class StorageTest(test.TestCase):
|
||||
def test_fetch_meapped_args(self):
|
||||
s = self._get_storage()
|
||||
s.inject({'foo': 'bar', 'spam': 'eggs'})
|
||||
self.assertEquals(s.fetch_mapped_args({'viking': 'spam'}),
|
||||
{'viking': 'eggs'})
|
||||
self.assertEqual(s.fetch_mapped_args({'viking': 'spam'}),
|
||||
{'viking': 'eggs'})
|
||||
|
||||
def test_fetch_not_found_args(self):
|
||||
s = self._get_storage()
|
||||
@ -291,7 +291,7 @@ class StorageTest(test.TestCase):
|
||||
state = states.PENDING
|
||||
s.add_task('42', 'my task')
|
||||
s.set_task_state('42', state)
|
||||
self.assertEquals(s.get_task_state('42'), state)
|
||||
self.assertEqual(s.get_task_state('42'), state)
|
||||
|
||||
def test_get_state_of_unknown_task(self):
|
||||
s = self._get_storage()
|
||||
@ -301,7 +301,7 @@ class StorageTest(test.TestCase):
|
||||
def test_task_by_name(self):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
self.assertEquals(s.get_uuid_by_name('my task'), '42')
|
||||
self.assertEqual(s.get_uuid_by_name('my task'), '42')
|
||||
|
||||
def test_unknown_task_by_name(self):
|
||||
s = self._get_storage()
|
||||
@ -311,7 +311,7 @@ class StorageTest(test.TestCase):
|
||||
|
||||
def test_initial_flow_state(self):
|
||||
s = self._get_storage()
|
||||
self.assertEquals(s.get_flow_state(), states.PENDING)
|
||||
self.assertEqual(s.get_flow_state(), states.PENDING)
|
||||
|
||||
def test_get_flow_state(self):
|
||||
_lb, fd = p_utils.temporary_flow_detail(backend=self.backend)
|
||||
@ -319,12 +319,12 @@ class StorageTest(test.TestCase):
|
||||
with contextlib.closing(self.backend.get_connection()) as conn:
|
||||
fd.update(conn.update_flow_details(fd))
|
||||
s = storage.Storage(flow_detail=fd, backend=self.backend)
|
||||
self.assertEquals(s.get_flow_state(), states.FAILURE)
|
||||
self.assertEqual(s.get_flow_state(), states.FAILURE)
|
||||
|
||||
def test_set_and_get_flow_state(self):
|
||||
s = self._get_storage()
|
||||
s.set_flow_state(states.SUCCESS)
|
||||
self.assertEquals(s.get_flow_state(), states.SUCCESS)
|
||||
self.assertEqual(s.get_flow_state(), states.SUCCESS)
|
||||
|
||||
@mock.patch.object(storage.LOG, 'warning')
|
||||
def test_result_is_checked(self, mocked_warning):
|
||||
@ -358,7 +358,7 @@ class StorageTest(test.TestCase):
|
||||
s.save('42', ['result'])
|
||||
mocked_warning.assert_called_once_with(
|
||||
mock.ANY, 'my task', 1, 'b')
|
||||
self.assertEquals(s.fetch('a'), 'result')
|
||||
self.assertEqual(s.fetch('a'), 'result')
|
||||
with self.assertRaisesRegexp(exceptions.NotFound,
|
||||
'^Unable to find result'):
|
||||
s.fetch('b')
|
||||
@ -368,7 +368,7 @@ class StorageTest(test.TestCase):
|
||||
s = self._get_storage()
|
||||
s.add_task('42', 'my task')
|
||||
s.set_result_mapping('42', {'result': 'key'})
|
||||
self.assertEquals(mocked_warning.mock_calls, [])
|
||||
self.assertEqual(mocked_warning.mock_calls, [])
|
||||
s.add_task('43', 'my other task')
|
||||
s.set_result_mapping('43', {'result': 'key'})
|
||||
mocked_warning.assert_called_once_with(
|
||||
@ -378,7 +378,7 @@ class StorageTest(test.TestCase):
|
||||
def test_multiple_providers_with_inject_are_checked(self, mocked_warning):
|
||||
s = self._get_storage()
|
||||
s.inject({'result': 'DONE'})
|
||||
self.assertEquals(mocked_warning.mock_calls, [])
|
||||
self.assertEqual(mocked_warning.mock_calls, [])
|
||||
s.add_task('43', 'my other task')
|
||||
s.set_result_mapping('43', {'result': 'key'})
|
||||
mocked_warning.assert_called_once_with(
|
||||
|
@ -96,11 +96,11 @@ class SuspendFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'engine': engine})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.SUCCESS)
|
||||
self.assertEquals(self.values, ['a'])
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.SUCCESS)
|
||||
self.assertEqual(self.values, ['a'])
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.SUCCESS)
|
||||
self.assertEquals(self.values, ['a'])
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.SUCCESS)
|
||||
self.assertEqual(self.values, ['a'])
|
||||
|
||||
def test_suspend_linear_flow(self):
|
||||
flow = lf.Flow('linear').add(
|
||||
@ -111,11 +111,11 @@ class SuspendFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'engine': engine})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
self.assertEquals(self.values, ['a', 'b'])
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
self.assertEqual(self.values, ['a', 'b'])
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.SUCCESS)
|
||||
self.assertEquals(self.values, ['a', 'b', 'c'])
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.SUCCESS)
|
||||
self.assertEqual(self.values, ['a', 'b', 'c'])
|
||||
|
||||
def test_suspend_linear_flow_on_revert(self):
|
||||
flow = lf.Flow('linear').add(
|
||||
@ -126,16 +126,16 @@ class SuspendFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'engine': engine})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
self.assertEquals(
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
self.assertEqual(
|
||||
self.values,
|
||||
['a', 'b',
|
||||
'c reverted(Failure: RuntimeError: Woot!)',
|
||||
'b reverted(5)'])
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.REVERTED)
|
||||
self.assertEquals(
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.REVERTED)
|
||||
self.assertEqual(
|
||||
self.values,
|
||||
['a',
|
||||
'b',
|
||||
@ -152,8 +152,8 @@ class SuspendFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'engine': engine})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
self.assertEquals(
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
self.assertEqual(
|
||||
self.values,
|
||||
['a', 'b',
|
||||
'c reverted(Failure: RuntimeError: Woot!)',
|
||||
@ -163,8 +163,8 @@ class SuspendFlowTest(utils.EngineTestBase):
|
||||
engine2 = self._make_engine(flow, engine.storage._flowdetail)
|
||||
with self.assertRaisesRegexp(RuntimeError, '^Woot'):
|
||||
engine2.run()
|
||||
self.assertEquals(engine2.storage.get_flow_state(), states.REVERTED)
|
||||
self.assertEquals(
|
||||
self.assertEqual(engine2.storage.get_flow_state(), states.REVERTED)
|
||||
self.assertEqual(
|
||||
self.values,
|
||||
['a',
|
||||
'b',
|
||||
@ -180,7 +180,7 @@ class SuspendFlowTest(utils.EngineTestBase):
|
||||
engine = self._make_engine(flow)
|
||||
engine.storage.inject({'engine': engine, 'boo': True})
|
||||
engine.run()
|
||||
self.assertEquals(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
self.assertEqual(engine.storage.get_flow_state(), states.SUSPENDED)
|
||||
# uninject engine
|
||||
engine.storage.save(
|
||||
engine.storage.get_uuid_by_name(engine.storage.injector_name),
|
||||
|
@ -47,28 +47,28 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_passed_name(self):
|
||||
my_task = MyTask(name='my name')
|
||||
self.assertEquals(my_task.name, 'my name')
|
||||
self.assertEqual(my_task.name, 'my name')
|
||||
|
||||
def test_generated_name(self):
|
||||
my_task = MyTask()
|
||||
self.assertEquals(my_task.name,
|
||||
'%s.%s' % (__name__, 'MyTask'))
|
||||
self.assertEqual(my_task.name,
|
||||
'%s.%s' % (__name__, 'MyTask'))
|
||||
|
||||
def test_no_provides(self):
|
||||
my_task = MyTask()
|
||||
self.assertEquals(my_task.save_as, {})
|
||||
self.assertEqual(my_task.save_as, {})
|
||||
|
||||
def test_provides(self):
|
||||
my_task = MyTask(provides='food')
|
||||
self.assertEquals(my_task.save_as, {'food': None})
|
||||
self.assertEqual(my_task.save_as, {'food': None})
|
||||
|
||||
def test_multi_provides(self):
|
||||
my_task = MyTask(provides=('food', 'water'))
|
||||
self.assertEquals(my_task.save_as, {'food': 0, 'water': 1})
|
||||
self.assertEqual(my_task.save_as, {'food': 0, 'water': 1})
|
||||
|
||||
def test_unpack(self):
|
||||
my_task = MyTask(provides=('food',))
|
||||
self.assertEquals(my_task.save_as, {'food': 0})
|
||||
self.assertEqual(my_task.save_as, {'food': 0})
|
||||
|
||||
def test_bad_provides(self):
|
||||
with self.assertRaisesRegexp(TypeError, '^Task provides'):
|
||||
@ -76,7 +76,7 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_requires_by_default(self):
|
||||
my_task = MyTask()
|
||||
self.assertEquals(my_task.rebind, {
|
||||
self.assertEqual(my_task.rebind, {
|
||||
'spam': 'spam',
|
||||
'eggs': 'eggs',
|
||||
'context': 'context'
|
||||
@ -84,7 +84,7 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_requires_amended(self):
|
||||
my_task = MyTask(requires=('spam', 'eggs'))
|
||||
self.assertEquals(my_task.rebind, {
|
||||
self.assertEqual(my_task.rebind, {
|
||||
'spam': 'spam',
|
||||
'eggs': 'eggs',
|
||||
'context': 'context'
|
||||
@ -93,7 +93,7 @@ class TaskTestCase(test.TestCase):
|
||||
def test_requires_explicit(self):
|
||||
my_task = MyTask(auto_extract=False,
|
||||
requires=('spam', 'eggs', 'context'))
|
||||
self.assertEquals(my_task.rebind, {
|
||||
self.assertEqual(my_task.rebind, {
|
||||
'spam': 'spam',
|
||||
'eggs': 'eggs',
|
||||
'context': 'context'
|
||||
@ -105,15 +105,15 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_requires_ignores_optional(self):
|
||||
my_task = DefaultArgTask()
|
||||
self.assertEquals(my_task.requires, set(['spam']))
|
||||
self.assertEqual(my_task.requires, set(['spam']))
|
||||
|
||||
def test_requires_allows_optional(self):
|
||||
my_task = DefaultArgTask(requires=('spam', 'eggs'))
|
||||
self.assertEquals(my_task.requires, set(['spam', 'eggs']))
|
||||
self.assertEqual(my_task.requires, set(['spam', 'eggs']))
|
||||
|
||||
def test_rebind_all_args(self):
|
||||
my_task = MyTask(rebind={'spam': 'a', 'eggs': 'b', 'context': 'c'})
|
||||
self.assertEquals(my_task.rebind, {
|
||||
self.assertEqual(my_task.rebind, {
|
||||
'spam': 'a',
|
||||
'eggs': 'b',
|
||||
'context': 'c'
|
||||
@ -121,7 +121,7 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_rebind_partial(self):
|
||||
my_task = MyTask(rebind={'spam': 'a', 'eggs': 'b'})
|
||||
self.assertEquals(my_task.rebind, {
|
||||
self.assertEqual(my_task.rebind, {
|
||||
'spam': 'a',
|
||||
'eggs': 'b',
|
||||
'context': 'context'
|
||||
@ -133,14 +133,14 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_rebind_unknown_kwargs(self):
|
||||
task = KwargsTask(rebind={'foo': 'bar'})
|
||||
self.assertEquals(task.rebind, {
|
||||
self.assertEqual(task.rebind, {
|
||||
'foo': 'bar',
|
||||
'spam': 'spam'
|
||||
})
|
||||
|
||||
def test_rebind_list_all(self):
|
||||
my_task = MyTask(rebind=('a', 'b', 'c'))
|
||||
self.assertEquals(my_task.rebind, {
|
||||
self.assertEqual(my_task.rebind, {
|
||||
'context': 'a',
|
||||
'spam': 'b',
|
||||
'eggs': 'c'
|
||||
@ -148,7 +148,7 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_rebind_list_partial(self):
|
||||
my_task = MyTask(rebind=('a', 'b'))
|
||||
self.assertEquals(my_task.rebind, {
|
||||
self.assertEqual(my_task.rebind, {
|
||||
'context': 'a',
|
||||
'spam': 'b',
|
||||
'eggs': 'eggs'
|
||||
@ -160,7 +160,7 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_rebind_list_more_kwargs(self):
|
||||
task = KwargsTask(rebind=('a', 'b', 'c'))
|
||||
self.assertEquals(task.rebind, {
|
||||
self.assertEqual(task.rebind, {
|
||||
'spam': 'a',
|
||||
'b': 'b',
|
||||
'c': 'c'
|
||||
@ -172,10 +172,10 @@ class TaskTestCase(test.TestCase):
|
||||
|
||||
def test_default_provides(self):
|
||||
task = DefaultProvidesTask()
|
||||
self.assertEquals(task.provides, set(['def']))
|
||||
self.assertEquals(task.save_as, {'def': None})
|
||||
self.assertEqual(task.provides, set(['def']))
|
||||
self.assertEqual(task.save_as, {'def': None})
|
||||
|
||||
def test_default_provides_can_be_overridden(self):
|
||||
task = DefaultProvidesTask(provides=('spam', 'eggs'))
|
||||
self.assertEquals(task.provides, set(['spam', 'eggs']))
|
||||
self.assertEquals(task.save_as, {'spam': 0, 'eggs': 1})
|
||||
self.assertEqual(task.provides, set(['spam', 'eggs']))
|
||||
self.assertEqual(task.save_as, {'spam': 0, 'eggs': 1})
|
||||
|
@ -45,8 +45,8 @@ class UnorderedFlowTest(test.TestCase):
|
||||
data = e.storage.fetch_all()
|
||||
self.assertIn('a', data)
|
||||
self.assertIn('b', data)
|
||||
self.assertEquals(2, data['b'])
|
||||
self.assertEquals(1, data['a'])
|
||||
self.assertEqual(2, data['b'])
|
||||
self.assertEqual(1, data['a'])
|
||||
|
||||
def test_reverting_flow(self):
|
||||
wf = uf.Flow("the-test-action")
|
||||
@ -73,4 +73,4 @@ class UnorderedFlowTest(test.TestCase):
|
||||
wf.add(DoApply2())
|
||||
e = self._make_engine(wf)
|
||||
e.run()
|
||||
self.assertEquals(2, len(e.storage.fetch('context')))
|
||||
self.assertEqual(2, len(e.storage.fetch('context')))
|
||||
|
@ -65,91 +65,91 @@ class GetCallableNameTest(test.TestCase):
|
||||
|
||||
def test_mere_function(self):
|
||||
name = reflection.get_callable_name(mere_function)
|
||||
self.assertEquals(name, '.'.join((__name__, 'mere_function')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'mere_function')))
|
||||
|
||||
def test_method(self):
|
||||
name = reflection.get_callable_name(Class.method)
|
||||
self.assertEquals(name, '.'.join((__name__, 'method')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'method')))
|
||||
|
||||
def test_instance_method(self):
|
||||
name = reflection.get_callable_name(Class().method)
|
||||
self.assertEquals(name, '.'.join((__name__, 'Class', 'method')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'Class', 'method')))
|
||||
|
||||
def test_static_method(self):
|
||||
# NOTE(imelnikov): static method are just functions, class name
|
||||
# is not recorded anywhere in them
|
||||
name = reflection.get_callable_name(Class.static_method)
|
||||
self.assertEquals(name, '.'.join((__name__, 'static_method')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'static_method')))
|
||||
|
||||
def test_class_method(self):
|
||||
name = reflection.get_callable_name(Class.class_method)
|
||||
self.assertEquals(name, '.'.join((__name__, 'Class', 'class_method')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'Class', 'class_method')))
|
||||
|
||||
def test_constructor(self):
|
||||
name = reflection.get_callable_name(Class)
|
||||
self.assertEquals(name, '.'.join((__name__, 'Class')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'Class')))
|
||||
|
||||
def test_callable_class(self):
|
||||
name = reflection.get_callable_name(CallableClass())
|
||||
self.assertEquals(name, '.'.join((__name__, 'CallableClass')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'CallableClass')))
|
||||
|
||||
def test_callable_class_call(self):
|
||||
name = reflection.get_callable_name(CallableClass().__call__)
|
||||
self.assertEquals(name, '.'.join((__name__, 'CallableClass',
|
||||
'__call__')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'CallableClass',
|
||||
'__call__')))
|
||||
|
||||
|
||||
class GetCallableArgsTest(test.TestCase):
|
||||
|
||||
def test_mere_function(self):
|
||||
result = reflection.get_callable_args(mere_function)
|
||||
self.assertEquals(['a', 'b'], result)
|
||||
self.assertEqual(['a', 'b'], result)
|
||||
|
||||
def test_function_with_defaults(self):
|
||||
result = reflection.get_callable_args(function_with_defs)
|
||||
self.assertEquals(['a', 'b', 'optional'], result)
|
||||
self.assertEqual(['a', 'b', 'optional'], result)
|
||||
|
||||
def test_required_only(self):
|
||||
result = reflection.get_callable_args(function_with_defs,
|
||||
required_only=True)
|
||||
self.assertEquals(['a', 'b'], result)
|
||||
self.assertEqual(['a', 'b'], result)
|
||||
|
||||
def test_method(self):
|
||||
result = reflection.get_callable_args(Class.method)
|
||||
self.assertEquals(['self', 'c', 'd'], result)
|
||||
self.assertEqual(['self', 'c', 'd'], result)
|
||||
|
||||
def test_instance_method(self):
|
||||
result = reflection.get_callable_args(Class().method)
|
||||
self.assertEquals(['c', 'd'], result)
|
||||
self.assertEqual(['c', 'd'], result)
|
||||
|
||||
def test_class_method(self):
|
||||
result = reflection.get_callable_args(Class.class_method)
|
||||
self.assertEquals(['g', 'h'], result)
|
||||
self.assertEqual(['g', 'h'], result)
|
||||
|
||||
def test_class_constructor(self):
|
||||
result = reflection.get_callable_args(ClassWithInit)
|
||||
self.assertEquals(['k', 'l'], result)
|
||||
self.assertEqual(['k', 'l'], result)
|
||||
|
||||
def test_class_with_call(self):
|
||||
result = reflection.get_callable_args(CallableClass())
|
||||
self.assertEquals(['i', 'j'], result)
|
||||
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.assertEquals(['x', 'y'], result)
|
||||
self.assertEqual(['x', 'y'], result)
|
||||
|
||||
|
||||
class AcceptsKwargsTest(test.TestCase):
|
||||
|
||||
def test_no_kwargs(self):
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
reflection.accepts_kwargs(mere_function), False)
|
||||
|
||||
def test_with_kwargs(self):
|
||||
self.assertEquals(
|
||||
self.assertEqual(
|
||||
reflection.accepts_kwargs(function_with_kwargs), True)
|
||||
|
||||
|
||||
@ -157,35 +157,35 @@ class GetClassNameTest(test.TestCase):
|
||||
|
||||
def test_std_exception(self):
|
||||
name = reflection.get_class_name(RuntimeError)
|
||||
self.assertEquals(name, 'RuntimeError')
|
||||
self.assertEqual(name, 'RuntimeError')
|
||||
|
||||
def test_global_class(self):
|
||||
name = reflection.get_class_name(misc.Failure)
|
||||
self.assertEquals(name, 'taskflow.utils.misc.Failure')
|
||||
self.assertEqual(name, 'taskflow.utils.misc.Failure')
|
||||
|
||||
def test_class(self):
|
||||
name = reflection.get_class_name(Class)
|
||||
self.assertEquals(name, '.'.join((__name__, 'Class')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'Class')))
|
||||
|
||||
def test_instance(self):
|
||||
name = reflection.get_class_name(Class())
|
||||
self.assertEquals(name, '.'.join((__name__, 'Class')))
|
||||
self.assertEqual(name, '.'.join((__name__, 'Class')))
|
||||
|
||||
def test_int(self):
|
||||
name = reflection.get_class_name(42)
|
||||
self.assertEquals(name, 'int')
|
||||
self.assertEqual(name, 'int')
|
||||
|
||||
|
||||
class GetAllClassNamesTest(test.TestCase):
|
||||
|
||||
def test_std_class(self):
|
||||
names = list(reflection.get_all_class_names(RuntimeError))
|
||||
self.assertEquals(names, test_utils.RUNTIME_ERROR_CLASSES)
|
||||
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.assertEquals(names, test_utils.RUNTIME_ERROR_CLASSES[:-2])
|
||||
self.assertEqual(names, test_utils.RUNTIME_ERROR_CLASSES[:-2])
|
||||
|
||||
|
||||
class AttrDictTest(test.TestCase):
|
||||
@ -195,8 +195,8 @@ class AttrDictTest(test.TestCase):
|
||||
'b': 2,
|
||||
}
|
||||
obj = misc.AttrDict(**attrs)
|
||||
self.assertEquals(obj.a, 1)
|
||||
self.assertEquals(obj.b, 2)
|
||||
self.assertEqual(obj.a, 1)
|
||||
self.assertEqual(obj.b, 2)
|
||||
|
||||
def test_private_create(self):
|
||||
attrs = {
|
||||
@ -223,15 +223,15 @@ class AttrDictTest(test.TestCase):
|
||||
'a': 1,
|
||||
}
|
||||
obj = misc.AttrDict(**attrs)
|
||||
self.assertEquals(obj.a, 1)
|
||||
self.assertEquals(attrs, dict(obj))
|
||||
self.assertEqual(obj.a, 1)
|
||||
self.assertEqual(attrs, dict(obj))
|
||||
|
||||
def test_runtime_invalid_set(self):
|
||||
attrs = {
|
||||
'a': 1,
|
||||
}
|
||||
obj = misc.AttrDict(**attrs)
|
||||
self.assertEquals(obj.a, 1)
|
||||
self.assertEqual(obj.a, 1)
|
||||
with self.assertRaises(AttributeError):
|
||||
obj._123 = 'b'
|
||||
|
||||
@ -240,18 +240,18 @@ class AttrDictTest(test.TestCase):
|
||||
'a': 1,
|
||||
}
|
||||
obj = misc.AttrDict(**attrs)
|
||||
self.assertEquals(1, obj['a'])
|
||||
self.assertEqual(1, obj['a'])
|
||||
|
||||
def test_bypass_set_no_get(self):
|
||||
attrs = {
|
||||
'a': 1,
|
||||
}
|
||||
obj = misc.AttrDict(**attrs)
|
||||
self.assertEquals(1, obj['a'])
|
||||
self.assertEqual(1, obj['a'])
|
||||
obj['_b'] = 'c'
|
||||
with self.assertRaises(AttributeError):
|
||||
obj._b = 'e'
|
||||
self.assertEquals('c', obj['_b'])
|
||||
self.assertEqual('c', obj['_b'])
|
||||
|
||||
|
||||
class ExcInfoUtilsTest(test.TestCase):
|
||||
|
@ -34,23 +34,23 @@ def _captured_failure(msg):
|
||||
class GeneralFailureObjTestsMixin(object):
|
||||
|
||||
def test_captures_message(self):
|
||||
self.assertEquals(self.fail_obj.exception_str, 'Woot!')
|
||||
self.assertEqual(self.fail_obj.exception_str, 'Woot!')
|
||||
|
||||
def test_str(self):
|
||||
self.assertEquals(str(self.fail_obj),
|
||||
'Failure: RuntimeError: Woot!')
|
||||
self.assertEqual(str(self.fail_obj),
|
||||
'Failure: RuntimeError: Woot!')
|
||||
|
||||
def test_exception_types(self):
|
||||
self.assertEquals(list(self.fail_obj),
|
||||
test_utils.RUNTIME_ERROR_CLASSES[:-2])
|
||||
self.assertEqual(list(self.fail_obj),
|
||||
test_utils.RUNTIME_ERROR_CLASSES[:-2])
|
||||
|
||||
def test_check_str(self):
|
||||
val = 'Exception'
|
||||
self.assertEquals(self.fail_obj.check(val), val)
|
||||
self.assertEqual(self.fail_obj.check(val), val)
|
||||
|
||||
def test_check_str_not_there(self):
|
||||
val = 'ValueError'
|
||||
self.assertEquals(self.fail_obj.check(val), None)
|
||||
self.assertEqual(self.fail_obj.check(val), None)
|
||||
|
||||
def test_check_type(self):
|
||||
self.assertIs(self.fail_obj.check(RuntimeError), RuntimeError)
|
||||
@ -70,8 +70,8 @@ class CaptureFailureTestCase(test.TestCase, GeneralFailureObjTestsMixin):
|
||||
|
||||
def test_captures_exc_info(self):
|
||||
exc_info = self.fail_obj.exc_info
|
||||
self.assertEquals(len(exc_info), 3)
|
||||
self.assertEquals(exc_info[0], RuntimeError)
|
||||
self.assertEqual(len(exc_info), 3)
|
||||
self.assertEqual(exc_info[0], RuntimeError)
|
||||
self.assertIs(exc_info[1], self.fail_obj.exception)
|
||||
|
||||
def test_reraises(self):
|
||||
@ -117,7 +117,7 @@ class FailureObjectTestCase(test.TestCase):
|
||||
exc_type_names=['Exception'],
|
||||
hi='hi there')
|
||||
expected = "Failure.__init__ got unexpected keyword argument(s): hi"
|
||||
self.assertEquals(str(ctx.exception), expected)
|
||||
self.assertEqual(str(ctx.exception), expected)
|
||||
|
||||
def test_empty_does_not_reraise(self):
|
||||
self.assertIs(misc.Failure.reraise_if_any([]), None)
|
||||
@ -134,14 +134,14 @@ class FailureObjectTestCase(test.TestCase):
|
||||
]
|
||||
with self.assertRaises(exceptions.WrappedFailure) as ctx:
|
||||
misc.Failure.reraise_if_any(fls)
|
||||
self.assertEquals(list(ctx.exception), fls)
|
||||
self.assertEqual(list(ctx.exception), fls)
|
||||
|
||||
def test_failure_copy(self):
|
||||
fail_obj = _captured_failure('Woot!')
|
||||
|
||||
copied = fail_obj.copy()
|
||||
self.assertIsNot(fail_obj, copied)
|
||||
self.assertEquals(fail_obj, copied)
|
||||
self.assertEqual(fail_obj, copied)
|
||||
self.assertTrue(fail_obj.matches(copied))
|
||||
|
||||
def test_failure_copy_recaptured(self):
|
||||
@ -151,7 +151,7 @@ class FailureObjectTestCase(test.TestCase):
|
||||
exc_type_names=list(captured))
|
||||
copied = fail_obj.copy()
|
||||
self.assertIsNot(fail_obj, copied)
|
||||
self.assertEquals(fail_obj, copied)
|
||||
self.assertEqual(fail_obj, copied)
|
||||
self.assertFalse(fail_obj != copied)
|
||||
self.assertTrue(fail_obj.matches(copied))
|
||||
|
||||
@ -167,7 +167,7 @@ class FailureObjectTestCase(test.TestCase):
|
||||
def test_two_captured_eq(self):
|
||||
captured = _captured_failure('Woot!')
|
||||
captured2 = _captured_failure('Woot!')
|
||||
self.assertEquals(captured, captured2)
|
||||
self.assertEqual(captured, captured2)
|
||||
|
||||
def test_two_recaptured_neq(self):
|
||||
captured = _captured_failure('Woot!')
|
||||
@ -178,12 +178,12 @@ class FailureObjectTestCase(test.TestCase):
|
||||
fail_obj2 = misc.Failure(exception_str=new_exc_str,
|
||||
traceback_str=captured.traceback_str,
|
||||
exc_type_names=list(captured))
|
||||
self.assertNotEquals(fail_obj, fail_obj2)
|
||||
self.assertNotEqual(fail_obj, fail_obj2)
|
||||
self.assertFalse(fail_obj2.matches(fail_obj))
|
||||
|
||||
def test_compares_to_none(self):
|
||||
captured = _captured_failure('Woot!')
|
||||
self.assertNotEquals(captured, None)
|
||||
self.assertNotEqual(captured, None)
|
||||
self.assertFalse(captured.matches(None))
|
||||
|
||||
|
||||
@ -192,14 +192,14 @@ class WrappedFailureTestCase(test.TestCase):
|
||||
def test_simple_iter(self):
|
||||
fail_obj = _captured_failure('Woot!')
|
||||
wf = exceptions.WrappedFailure([fail_obj])
|
||||
self.assertEquals(len(wf), 1)
|
||||
self.assertEquals(list(wf), [fail_obj])
|
||||
self.assertEqual(len(wf), 1)
|
||||
self.assertEqual(list(wf), [fail_obj])
|
||||
|
||||
def test_simple_check(self):
|
||||
fail_obj = _captured_failure('Woot!')
|
||||
wf = exceptions.WrappedFailure([fail_obj])
|
||||
self.assertEquals(wf.check(RuntimeError), RuntimeError)
|
||||
self.assertEquals(wf.check(ValueError), None)
|
||||
self.assertEqual(wf.check(RuntimeError), RuntimeError)
|
||||
self.assertEqual(wf.check(ValueError), None)
|
||||
|
||||
def test_two_failures(self):
|
||||
fls = [
|
||||
@ -207,8 +207,8 @@ class WrappedFailureTestCase(test.TestCase):
|
||||
_captured_failure('Oh, not again!')
|
||||
]
|
||||
wf = exceptions.WrappedFailure(fls)
|
||||
self.assertEquals(len(wf), 2)
|
||||
self.assertEquals(list(wf), fls)
|
||||
self.assertEqual(len(wf), 2)
|
||||
self.assertEqual(list(wf), fls)
|
||||
|
||||
def test_flattening(self):
|
||||
f1 = _captured_failure('Wrap me')
|
||||
@ -220,4 +220,4 @@ class WrappedFailureTestCase(test.TestCase):
|
||||
fail_obj = misc.Failure()
|
||||
|
||||
wf = exceptions.WrappedFailure([fail_obj, f3])
|
||||
self.assertEquals(list(wf), [f1, f2, f3])
|
||||
self.assertEqual(list(wf), [f1, f2, f3])
|
||||
|
Loading…
Reference in New Issue
Block a user