GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 87567b55 authored by Olof Svensson's avatar Olof Svensson

BES-315: New test workfow 10 with a loop

parent 6b6aee88
#
# Copyright (c) European Synchrotron Radiation Facility (ESRF)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__authors__ = ["O. Svensson"]
__license__ = "MIT"
__date__ = "03/05/2021"
def run(value=None, limit=10, **kwargs):
if value is None:
raise RuntimeError("Missing argument 'value'!")
if limit is None:
raise RuntimeError("Missing argument 'limit'!")
doContinue = "true"
value += 1
if value >= limit:
doContinue = "false"
return {
"value": value,
"doContinue": doContinue
}
#
# Copyright (c) European Synchrotron Radiation Facility (ESRF)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__authors__ = ["O. Svensson"]
__license__ = "MIT"
__date__ = "03/05/2021"
import logging
import unittest
from pypushflow.Workflow import Workflow
from pypushflow.StopActor import StopActor
from pypushflow.StartActor import StartActor
from pypushflow.PythonActor import PythonActor
from pypushflow.RouterActor import RouterActor
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('testWorkflow')
class Workflow10(Workflow):
def __init__(self, name):
Workflow.__init__(self, name)
self.startActor = StartActor(self)
self.pythonActorAddAndCheck = PythonActor(
parent=self,
script='pypushflow.test.pythonActorAddAndCheck.py',
name='Python add and check',
)
self.check = RouterActor(
parent=self,
name='Check',
itemName="doContinue",
listPort=["true", "false"]
)
self.stopActor = StopActor(self)
self.startActor.connect(self.pythonActorAddAndCheck)
self.pythonActorAddAndCheck.connect(self.check)
self.check.connect(self.pythonActorAddAndCheck, expectedValue="true")
self.check.connect(self.stopActor, expectedValue="false")
def run(self, inData):
self.startActor.trigger(inData)
self.stopActor.join(timeout=1200)
return self.stopActor.outData
class TestWorkflow10(unittest.TestCase):
def test_workflow10_10(self):
limit = 10
workflow10 = Workflow10('Test workflow {0}'.format(limit))
inData = {'value': 1, 'limit': limit}
outData = workflow10.run(inData)
self.assertEqual(outData['value'], limit)
def test_workflow10_100(self):
limit = 100
workflow10 = Workflow10('Test workflow {0}'.format(limit))
inData = {'value': 1, 'limit': limit}
outData = workflow10.run(inData)
self.assertEqual(outData['value'], limit)
def test_workflow10_200(self):
limit = 200
workflow10 = Workflow10('Test workflow {0}'.format(limit))
inData = {'value': 1, 'limit': limit}
outData = workflow10.run(inData)
self.assertEqual(outData['value'], limit)
def test_workflow10_300(self):
limit = 300
workflow10 = Workflow10('Test workflow {0}'.format(limit))
inData = {'value': 1, 'limit': limit}
outData = workflow10.run(inData)
self.assertEqual(outData['value'], limit)
# def test_workflow10_400(self):
# limit = 400
# workflow10 = Workflow10('Test workflow {0}'.format(limit))
# inData = {'value': 1, 'limit': limit}
# outData = workflow10.run(inData)
# self.assertEqual(outData['value'], limit)
#
# def test_workflow10_500(self):
# limit = 500
# workflow10 = Workflow10('Test workflow {0}'.format(limit))
# inData = {'value': 1, 'limit': limit}
# outData = workflow10.run(inData)
# self.assertEqual(outData['value'], limit)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment