Exemplo n.º 1
0
 def test_already_registered(self):
     from flowy import SWFWorkflowConfig, SWFWorkflowWorker
     worker = SWFWorkflowWorker()
     w = SWFWorkflowConfig()
     worker.register(w, lambda: 1, name='T', version=1)
     self.assertRaises(
         ValueError,
         lambda: worker.register(w, lambda: 1, name='T', version=1))
Exemplo n.º 2
0
    result = None
    if a is not None and b is not None:
        result = a + b
    elif a is not None:
        result = a * a
    if sleep is not None and RECORDING:
        time.sleep(sleep)
    if heartbeat:
        hb()
    if err is not None:
        raise RuntimeError(err)
    return result


empty_conf = SWFWorkflowConfig(default_task_list=TASKLIST,
                               default_decision_duration=10,
                               default_workflow_duration=20,
                               default_child_policy='TERMINATE', )
empty_conf.conf_activity('activity', VERSION, 'tactivity')


@empty_conf(version=VERSION)
class TWorkflow(object):
    def __init__(self, activity):
        pass

    def __call__(self, a=None, b=None, sleep=None, heartbeat=False, err=None):
        dummy_heartbeat = lambda: True
        return tactivity(dummy_heartbeat, a, b, sleep, heartbeat, err)


conf_use_activities = SWFWorkflowConfig(default_task_list=TASKLIST,
Exemplo n.º 3
0
    if a is not None and b is not None:
        result = a + b
    elif a is not None:
        result = a * a
    if sleep is not None and RECORDING:
        time.sleep(sleep)
    if heartbeat:
        hb()
    if err is not None:
        raise RuntimeError(err)
    return result


empty_conf = SWFWorkflowConfig(
    default_task_list=TASKLIST,
    default_decision_duration=10,
    default_workflow_duration=20,
    default_child_policy="TERMINATE",
)
empty_conf.conf_activity("activity", VERSION, "tactivity")


@empty_conf(version=VERSION)
class TWorkflow(object):
    def __init__(self, activity):
        pass

    def __call__(self, a=None, b=None, sleep=None, heartbeat=False, err=None):
        dummy_heartbeat = lambda: True
        return tactivity(dummy_heartbeat, a, b, sleep, heartbeat, err)

Exemplo n.º 4
0
from flowy import SWFWorkflowConfig
from flowy import SWFWorkflowWorker

from workflows import *

no_activity_workflow = SWFWorkflowConfig()

task_activity_workflow = SWFWorkflowConfig()
task_activity_workflow.conf_activity('task', version=1)

task_activity_workflow_rl = SWFWorkflowConfig(rate_limit=3)
task_activity_workflow_rl.conf_activity('task', version=1)

sa_workflow_custom_timers = SWFWorkflowConfig()
sa_workflow_custom_timers.conf_activity(
    'task',
    version=1,
    heartbeat=10,
    schedule_to_start=11,
    schedule_to_close=12,
    start_to_close=13,
    task_list='TL',
)

sa_workflow_custom_timers_W = SWFWorkflowConfig()
sa_workflow_custom_timers_W.conf_workflow('task',
                                          version=1,
                                          decision_duration=10,
                                          workflow_duration=11,
                                          task_list='TL',
                                          child_policy='TERMINATE')
Exemplo n.º 5
0
 def test_duplicate_name(self):
     from flowy import SWFWorkflowConfig
     w = SWFWorkflowConfig()
     w.conf_proxy_factory('task', None)
     self.assertRaises(ValueError, lambda: w.conf_proxy_factory('task', None))
Exemplo n.º 6
0
 def test_nonalnum_name(self):
     from flowy import SWFWorkflowConfig
     w = SWFWorkflowConfig()
     self.assertRaises(ValueError, lambda: w.conf_proxy_factory('abc!123', None))
Exemplo n.º 7
0
 def test_keyword_name(self):
     from flowy import SWFWorkflowConfig
     w = SWFWorkflowConfig()
     self.assertRaises(ValueError, lambda: w.conf_proxy_factory('for', None))
Exemplo n.º 8
0
    def test_digit_name(self):
        from flowy import SWFWorkflowConfig

        w = SWFWorkflowConfig()
        self.assertRaises(ValueError, lambda: w.conf_proxy_factory("123", None))
Exemplo n.º 9
0
 def test_duplicate_name(self):
     from flowy import SWFWorkflowConfig
     w = SWFWorkflowConfig()
     w.conf_proxy_factory('task', None)
     self.assertRaises(ValueError,
                       lambda: w.conf_proxy_factory('task', None))
Exemplo n.º 10
0
 def test_nonalnum_name(self):
     from flowy import SWFWorkflowConfig
     w = SWFWorkflowConfig()
     self.assertRaises(ValueError,
                       lambda: w.conf_proxy_factory('abc!123', None))
Exemplo n.º 11
0
 def test_keyword_name(self):
     from flowy import SWFWorkflowConfig
     w = SWFWorkflowConfig()
     self.assertRaises(ValueError,
                       lambda: w.conf_proxy_factory('for', None))
Exemplo n.º 12
0
from flowy import SWFWorkflowConfig
from flowy import SWFWorkflowWorker

from flowy.tests.workflows import *

no_activity_workflow = SWFWorkflowConfig()

task_activity_workflow = SWFWorkflowConfig()
task_activity_workflow.conf_activity('task', version=1)

task_activity_workflow_rl = SWFWorkflowConfig(rate_limit=3)
task_activity_workflow_rl.conf_activity('task', version=1)

sa_workflow_custom_timers = SWFWorkflowConfig()
sa_workflow_custom_timers.conf_activity('task',
                                     version=1,
                                     heartbeat=10,
                                     schedule_to_start=11,
                                     schedule_to_close=12,
                                     start_to_close=13,
                                     task_list='TL', )

sa_workflow_custom_timers_W = SWFWorkflowConfig()
sa_workflow_custom_timers_W.conf_workflow('task',
                                      version=1,
                                      decision_duration=10,
                                      workflow_duration=11,
                                      task_list='TL',
                                      child_policy='TERMINATE')
task_red_activities_workflow = SWFWorkflowConfig()
task_red_activities_workflow.conf_activity('task', version=1)
Exemplo n.º 13
0
    if a is not None and b is not None:
        result = a + b
    elif a is not None:
        result = a * a
    if sleep is not None and RECORDING:
        time.sleep(sleep)
    if heartbeat:
        hb()
    if err is not None:
        raise RuntimeError(err)
    return result


empty_conf = SWFWorkflowConfig(
    default_task_list=TASKLIST,
    default_decision_duration=10,
    default_workflow_duration=20,
    default_child_policy='TERMINATE',
)
empty_conf.conf_activity('activity', VERSION, 'tactivity')


@empty_conf(version=VERSION)
class TWorkflow(object):
    def __init__(self, activity):
        pass

    def __call__(self, a=None, b=None, sleep=None, heartbeat=False, err=None):
        dummy_heartbeat = lambda: True
        return tactivity(dummy_heartbeat, a, b, sleep, heartbeat, err)