Beispiel #1
0
    def test_invoke_with_activity_options(self):
        class HelloActivities:
            @activity_method(task_list="test-tasklist")
            def hello(self, arg1, arg2):
                pass

        stub = HelloActivities()
        stub._decision_context = self.decision_context
        stub._retry_parameters = None
        stub._activity_options = ActivityOptions(
            schedule_to_close_timeout_seconds=50,
            schedule_to_start_timeout_seconds=100,
            start_to_close_timeout_seconds=150,
            heartbeat_timeout_seconds=200,
            task_list="tasklist-tasklist-tasklist")

        async def fn():
            await stub.hello(1, "one")

        loop = get_event_loop()
        self.task = loop.create_task(fn())
        run_once(loop)

        self.decision_context.schedule_activity_task.assert_called_once()
        args, kwargs = self.decision_context.schedule_activity_task.call_args_list[
            0]
        parameters: ExecuteActivityParameters = kwargs["parameters"]
        self.assertEquals(parameters.schedule_to_close_timeout_seconds, 50)
        self.assertEquals(parameters.schedule_to_start_timeout_seconds, 100)
        self.assertEquals(parameters.start_to_close_timeout_seconds, 150)
        self.assertEquals(parameters.heartbeat_timeout_seconds, 200)
        self.assertEquals(parameters.task_list, "tasklist-tasklist-tasklist")
Beispiel #2
0
 def test_await_till_no_progress(self):
     self.task = self.event_loop.create_task(
         self.itask.await_till(lambda *args: None))
     run_once(self.event_loop)
     assert self.itask.awaited
     run_once(self.event_loop)
     assert self.itask.awaited
Beispiel #3
0
    def test_unblock(self):
        blocked = True

        def check_blocked():
            nonlocal blocked
            return not blocked

        self.task = self.event_loop.create_task(
            self.itask.await_till(check_blocked))
        run_once(self.event_loop)
        blocked = False
        self.itask.unblock()
        run_once(self.event_loop)
        assert not self.itask.awaited
    def test_invoke_stub_with_args(self):
        class HelloActivities:
            @activity_method(task_list="test-tasklist")
            def hello(self, arg1, arg2):
                pass

        stub = HelloActivities()
        stub._decision_context = self.decision_context

        async def fn():
            await stub.hello(1, "one")

        loop = get_event_loop()
        self.task = loop.create_task(fn())
        run_once(loop)

        self.decision_context.schedule_activity_task.assert_called_once()
        args, kwargs = self.decision_context.schedule_activity_task.call_args_list[0]
        self.assertEqual(b'[1, "one"]', kwargs["parameters"].input)