def test_reentrant_dispatch(self): _run(ActorRuntime.register_actor(FakeMultiInterfacesActor)) request_body = { "message": "hello dapr", } reentrancy_id = "0faa4c8b-f53a-4dff-9a9d-c50205035085" test_request_body = self._serializer.serialize(request_body) response = _run( ActorRuntime.dispatch(FakeMultiInterfacesActor.__name__, 'test-id', "ReentrantMethod", test_request_body, reentrancy_id=reentrancy_id)) self.assertEqual(b'"hello dapr"', response) _run( ActorRuntime.deactivate(FakeMultiInterfacesActor.__name__, 'test-id')) # Ensure test-id is deactivated with self.assertRaises(ValueError): _run( ActorRuntime.deactivate(FakeMultiInterfacesActor.__name__, 'test-id'))
def test_dispatch(self): _run(ActorRuntime.register_actor(FakeMultiInterfacesActor)) request_body = { "message": "hello dapr", } test_request_body = self._serializer.serialize(request_body) response = _run(ActorRuntime.dispatch( FakeMultiInterfacesActor.__name__, 'test-id', "ActionMethod", test_request_body)) self.assertEqual(b'"hello dapr"', response) _run(ActorRuntime.deactivate(FakeMultiInterfacesActor.__name__, 'test-id')) # Ensure test-id is deactivated with self.assertRaises(ValueError): _run(ActorRuntime.deactivate(FakeMultiInterfacesActor.__name__, 'test-id'))
def test_header_passthrough_reentrancy_disabled(self): config = ActorRuntimeConfig(reentrancy=None) ActorRuntime.set_actor_config(config) _run(ActorRuntime.register_actor(FakeReentrantActor)) _run(ActorRuntime.register_actor(FakeSlowReentrantActor)) request_body = self._serializer.serialize({ "message": "Normal", }) async def expected_return_value(*args, **kwargs): return ["expected", "None"] reentrancy_id = "f6319f23-dc0a-4880-90d9-87b23c19c20a" actor = FakeSlowReentrantActor.__name__ method = 'ReentrantMethod' with mock.patch('dapr.clients.http.client.DaprHttpClient.send_bytes' ) as mocked: mocked.side_effect = expected_return_value _run( ActorRuntime.dispatch(FakeReentrantActor.__name__, 'test-id', 'ReentrantMethodWithPassthrough', request_body, reentrancy_id=reentrancy_id)) mocked.assert_called_with( method="POST", url= f'http://127.0.0.1:3500/v1.0/actors/{actor}/test-id/method/{method}', data=None, headers={}) _run(ActorRuntime.deactivate(FakeReentrantActor.__name__, 'test-id')) # Ensure test-id is deactivated with self.assertRaises(ValueError): _run( ActorRuntime.deactivate(FakeReentrantActor.__name__, 'test-id'))