From a395f3e2c14a1edeb4613ad9b82e53fcb501de3e Mon Sep 17 00:00:00 2001 From: "Ivan A. Melnikov" Date: Fri, 21 Mar 2014 12:17:01 +0400 Subject: [PATCH] Drop obsolete test_unordered_flow Action engine tests were modified to keep few cases covered. Change-Id: Ibfcdd5378605532a4eb3fb1a43a70532a771ea16 --- taskflow/tests/unit/test_action_engine.py | 7 +- taskflow/tests/unit/test_unordered_flow.py | 74 ---------------------- taskflow/tests/utils.py | 20 ------ 3 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 taskflow/tests/unit/test_unordered_flow.py diff --git a/taskflow/tests/unit/test_action_engine.py b/taskflow/tests/unit/test_action_engine.py index 28429d06..c095f086 100644 --- a/taskflow/tests/unit/test_action_engine.py +++ b/taskflow/tests/unit/test_action_engine.py @@ -205,10 +205,12 @@ class EngineParallelFlowTest(utils.EngineTestBase): def test_parallel_flow_one_task(self): flow = uf.Flow('p-1').add( - utils.SaveOrderTask(name='task1') + utils.SaveOrderTask(name='task1', provides='a') ) - self._make_engine(flow).run() + engine = self._make_engine(flow) + engine.run() self.assertEqual(self.values, ['task1']) + self.assertEqual(engine.storage.fetch_all(), {'a': 5}) def test_parallel_flow_two_tasks(self): flow = uf.Flow('p-2').add( @@ -219,7 +221,6 @@ class EngineParallelFlowTest(utils.EngineTestBase): result = set(self.values) self.assertEqual(result, set(['task1', 'task2'])) - self.assertEqual(len(flow), 2) def test_parallel_revert(self): flow = uf.Flow('p-r-3').add( diff --git a/taskflow/tests/unit/test_unordered_flow.py b/taskflow/tests/unit/test_unordered_flow.py deleted file mode 100644 index d824f50b..00000000 --- a/taskflow/tests/unit/test_unordered_flow.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2012 Yahoo! Inc. 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 taskflow.engines - -from taskflow.patterns import unordered_flow as uf -from taskflow import task -from taskflow import test - -from taskflow.tests import utils - - -class UnorderedFlowTest(test.TestCase): - def _make_engine(self, flow): - return taskflow.engines.load(flow, store={'context': {}}) - - def test_result_access(self): - - class DoApply(task.Task): - default_provides = ('a', 'b') - - def execute(self): - return [1, 2] - - wf = uf.Flow("the-test-action") - wf.add(DoApply()) - - e = self._make_engine(wf) - e.run() - data = e.storage.fetch_all() - self.assertIn('a', data) - self.assertIn('b', data) - self.assertEqual(2, data['b']) - self.assertEqual(1, data['a']) - - def test_reverting_flow(self): - wf = uf.Flow("the-test-action") - wf.add(utils.make_reverting_task('1')) - wf.add(utils.make_reverting_task('2', blowup=True)) - e = self._make_engine(wf) - self.assertRaisesRegexp(RuntimeError, '^I blew up', e.run) - - def test_functor_flow(self): - - class DoApply1(task.Task): - default_provides = ('a', 'b', 'c') - - def execute(self, context): - context['1'] = True - return ['a', 'b', 'c'] - - class DoApply2(task.Task): - def execute(self, context): - context['2'] = True - - wf = uf.Flow("the-test-action") - wf.add(DoApply1()) - wf.add(DoApply2()) - e = self._make_engine(wf) - e.run() - self.assertEqual(2, len(e.storage.fetch('context'))) diff --git a/taskflow/tests/utils.py b/taskflow/tests/utils.py index 6c4d6ae3..3abc1edb 100644 --- a/taskflow/tests/utils.py +++ b/taskflow/tests/utils.py @@ -45,26 +45,6 @@ def wrap_all_failures(): raise exceptions.WrappedFailure([misc.Failure()]) -def make_reverting_task(token, blowup=False): - - def do_revert(context, *args, **kwargs): - context[token] = 'reverted' - - if blowup: - - def blow_up(context, *args, **kwargs): - raise RuntimeError("I blew up") - - return task.FunctorTask(blow_up, name='blowup_%s' % token) - else: - - def do_apply(context, *args, **kwargs): - context[token] = 'passed' - - return task.FunctorTask(do_apply, revert=do_revert, - name='do_apply_%s' % token) - - class DummyTask(task.Task): def execute(self, context, *args, **kwargs):