Example #1
0
    def test_old_wf_results(self):
        wf = WorkflowDemo()
        wf.start()
        while wf.is_running():
            execute_steps()

        class _TestWf(WorkChain):
            @classmethod
            def define(cls, spec):
                super(_TestWf, cls).define(spec)
                spec.outline(cls.start, cls.check)

            def start(self):
                return ToContext(res=Outputs(legacy_workflow(wf.pk)))

            def check(self):
                assert set(self.ctx.res) == set(wf.get_results())

        _TestWf.new_instance().run_until_complete()
Example #2
0
    def test_call_old_wf(self):
        wf = WorkflowDemo()
        wf.start()
        while wf.is_running():
            execute_steps()

        class _TestWf(WorkChain):
            @classmethod
            def define(cls, spec):
                super(_TestWf, cls).define(spec)
                spec.outline(cls.start, cls.check)

            def start(self):
                return ToContext(wf=legacy_workflow(wf.pk))

            def check(self):
                assert self.ctx.wf is not None

        _TestWf.new_instance().run_until_complete()
Example #3
0
    def test_call_old_wf(self):
        wf = WorkflowDemo()
        wf.start()
        while wf.is_running():
            execute_steps()

        class _TestWf(WorkChain):
            @classmethod
            def define(cls, spec):
                super(_TestWf, cls).define(spec)
                spec.outline(cls.begin, cls.check)

            def begin(self):
                return ToContext(wf=wf)

            def check(self):
                assert self.ctx.wf is not None

        run_and_check_success(_TestWf)
Example #4
0
    def test_old_wf_results(self):
        wf = WorkflowDemo()
        wf.start()
        while wf.is_running():
            execute_steps()

        test_case = self

        class _TestWf(WorkChain):
            @classmethod
            def define(cls, spec):
                super(_TestWf, cls).define(spec)
                spec.outline(cls.begin, cls.check)

            def begin(self):
                return ToContext(res=wf)

            def check(self):
                test_case.assertEquals(self.ctx.res.pk, wf.pk)

        run_and_check_success(_TestWf)
Example #5
0
    def test_call_on_wf_finish(self):
        loop = self.runner.loop
        future = plumpy.Future()

        # Need to start() so it's stored
        wf = WorkflowDemo()
        wf.start()

        def wf_done(pk):
            self.assertEqual(pk, wf.pk)
            loop.stop()
            future.set_result(True)

        self.runner.call_on_legacy_workflow_finish(wf.pk, wf_done)

        # Run the wf
        while wf.is_running():
            execute_steps()

        self._run_loop_for(10.)
        self.assertTrue(future.result())