コード例 #1
0
class TestActor(unittest.TestCase):
    def make_swf_environment(self):
        conn = boto.connect_swf()
        conn.register_domain("TestDomain", "50")
        conn.register_workflow_type(
            "TestDomain", "test-workflow", "v1.2",
            task_list="test-task-list", default_child_policy="TERMINATE",
            default_execution_start_to_close_timeout="6",
            default_task_start_to_close_timeout="3",
        )
        return conn

    def setUp(self):
        self.domain = Domain("TestDomain")
        self.actor = Decider(self.domain, "test-task-list")

    def tearDown(self):
        pass

    @mock_swf
    def test_poll_with_no_decision_to_take(self):
        conn = self.make_swf_environment()
        with self.assertRaises(PollTimeout):
            self.actor.poll()

    @mock_swf
    def test_poll_with_decision_to_take(self):
        conn = self.make_swf_environment()
        conn.start_workflow_execution("TestDomain", "wfe-1234", "test-workflow", "v1.2")

        response = self.actor.poll()

        self.assertIsNotNone(response.token)
        self.assertEqual(
            [evt.type for evt in response.history],
            ['WorkflowExecution', 'DecisionTask', 'DecisionTask']
        )
        self.assertEqual(response.execution.workflow_id, 'wfe-1234')
        self.assertIsNotNone(response.execution.run_id)
コード例 #2
0
 def setUp(self):
     self.domain = Domain("TestDomain")
     self.actor = Decider(self.domain, "test-task-list")
コード例 #3
0
 def build_decisions(self, workflow_class):
     self.decider = Decider(self.domain, self.decision_task_list)
     response = self.decider.poll()
     self._decision_token = response.token
     self.executor = Executor(self.domain, workflow_class)
     return self.executor.replay(response)
コード例 #4
0
class MockSWFTestCase(unittest.TestCase):

    def setUp(self):
        # SWF preparation
        self.domain = DOMAIN
        self.workflow_type_name = "test-workflow"
        self.workflow_type_version = "v1.2"
        self.decision_task_list = "test-task-list"

        self.conn = boto.connect_swf()
        self.conn.register_domain(self.domain.name, "50")
        self.conn.register_workflow_type(
            self.domain.name, self.workflow_type_name, self.workflow_type_version,
            task_list=self.decision_task_list, default_child_policy="TERMINATE",
            default_execution_start_to_close_timeout="6",
            default_task_start_to_close_timeout="3",
        )

        # S3 preparation in case we use jumbo fields
        self.s3_conn = boto.connect_s3()
        self.s3_conn.create_bucket("jumbo-bucket")

    def tearDown(self):
        swf_backend.reset()
        assert not self.conn.list_domains("REGISTERED")["domainInfos"], \
            "moto state incorrectly reset!"

    def register_activity_type(self, func, task_list):
        self.conn.register_activity_type(self.domain.name, func, task_list)

    def start_workflow_execution(self, input=None):
        self.workflow_id = "wfe-1234"
        response = self.conn.start_workflow_execution(
            self.domain.name, self.workflow_id,
            self.workflow_type_name, self.workflow_type_version,
            input=input,
        )
        self.run_id = response["runId"]

    def build_decisions(self, workflow_class):
        self.decider = Decider(self.domain, self.decision_task_list)
        response = self.decider.poll()
        self._decision_token = response.token
        self.executor = Executor(self.domain, workflow_class)
        return self.executor.replay(response)

    def take_decisions(self, decisions, execution_context=None):
        self.decider.complete(self._decision_token,
                              decisions=decisions,
                              execution_context=execution_context)

    def get_workflow_execution_history(self):
        return self.conn.get_workflow_execution_history(
            self.domain.name, workflow_id=self.workflow_id, run_id=self.run_id,
        )

    def process_activity_task(self):
        poller = ActivityPoller(self.domain, "default")
        response = poller.poll(identity="tst")
        worker = ActivityWorker()
        worker.process(poller, response.task_token, response.activity_task)
コード例 #5
0
class MockSWFTestCase(unittest.TestCase):

    def setUp(self):
        # SWF preparation
        self.domain = DOMAIN
        self.workflow_type_name = "test-workflow"
        self.workflow_type_version = "v1.2"
        self.decision_task_list = "test-task-list"

        self.conn = boto.connect_swf()
        self.conn.register_domain(self.domain.name, "50")
        self.conn.register_workflow_type(
            self.domain.name, self.workflow_type_name, self.workflow_type_version,
            task_list=self.decision_task_list, default_child_policy="TERMINATE",
            default_execution_start_to_close_timeout="6",
            default_task_start_to_close_timeout="3",
        )

        # S3 preparation in case we use jumbo fields
        self.s3_conn = boto.connect_s3()
        self.s3_conn.create_bucket("jumbo-bucket")

    def tearDown(self):
        swf_backend.reset()
        assert not self.conn.list_domains("REGISTERED")["domainInfos"], \
            "moto state incorrectly reset!"

    def register_activity_type(self, func, task_list):
        self.conn.register_activity_type(self.domain.name, func, task_list)

    def start_workflow_execution(self, input=None):
        self.workflow_id = "wfe-1234"
        response = self.conn.start_workflow_execution(
            self.domain.name, self.workflow_id,
            self.workflow_type_name, self.workflow_type_version,
            input=input,
        )
        self.run_id = response["runId"]

    def build_decisions(self, workflow_class):
        self.decider = Decider(self.domain, self.decision_task_list)
        response = self.decider.poll()
        self._decision_token = response.token
        self.executor = Executor(self.domain, workflow_class)
        return self.executor.replay(response)

    def take_decisions(self, decisions, execution_context=None):
        self.decider.complete(self._decision_token,
                              decisions=decisions,
                              execution_context=execution_context)

    def get_workflow_execution_history(self):
        return self.conn.get_workflow_execution_history(
            self.domain.name, workflow_id=self.workflow_id, run_id=self.run_id,
        )

    def process_activity_task(self):
        poller = ActivityPoller(self.domain, "default")
        response = poller.poll(identity="tst")
        worker = ActivityWorker()
        worker.process(poller, response.task_token, response.activity_task)
コード例 #6
0
ファイル: test_decider.py プロジェクト: xzased/simpleflow
 def setUp(self):
     self.domain = Domain("TestDomain")
     self.actor = Decider(self.domain, "test-task-list")