Skip to content

Commit 9314788

Browse files
Lorenzo CurcioLorenzo Curcio
Lorenzo Curcio
authored and
Lorenzo Curcio
committed
documentation changes
Signed-off-by: Lorenzo Curcio <[email protected]>
1 parent e391eda commit 9314788

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

daprdocs/content/en/python-sdk-docs/python-actor.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ result = await mock_actor.recieve_reminder(name, state, due_time, period, _ttl)
9999

100100
### Usage and Limitations
101101

102-
**The `_on_activate` method will not be called automatically the way it is when Dapr initializes a new Actor instance. You should call it manually as needed as part of your tests.**
102+
**To allow for more fine-grained control, the `_on_activate` method will not be called automatically the way it is when Dapr initializes a new Actor instance. You should call it manually as needed as part of your tests.**
103103

104104
The `__init__`, `register_timer`, `unregister_timer`, `register_reminder`, `unregister_reminder` methods are all overwritten by the MockActor class that gets applied as a mixin via `create_mock_actor`. If your actor itself overwrites these methods, those modifications will themselves be overwritten and the actor will likely not behave as you expect.
105105

@@ -110,9 +110,11 @@ The `__init__`, `register_timer`, `unregister_timer`, `register_reminder`, `unre
110110
```
111111
*Mock actors work fine with this, but if you have added any extra logic into `__init__`, it will be overwritten. It is worth noting that the correct way to apply logic on initialization is via `_on_activate` (which can also be safely used with mock actors) instead of `__init__`.*
112112

113-
The actor `_runtime_ctx` variable is set to None. All the normal actor methods have been overwritten such as to not call it, but if your code itself interacts directly with `_runtime_ctx`, it will likely break.
113+
*If you have an actor which does override default Dapr actor methods, your best bet is likely to create a custom subclass of the MockActor class (from MockActor.py) which implements whatever custom logic you have along with interacting with `_mock_state`, `_mock_timers`, and `_mock_reminders` as normal, and then appyling that custom class as a mixin via a `create_mock_actor` function you define yourself.*
114114

115-
The actor _state_manager is overwritten with an instance of `MockStateManager`. This has all the same methods and functionality of the base `ActorStateManager`, except for using the various `_mock` variables for storing data instead of the `_runtime_ctx`. If your code implements its own custom state manager it will be overwritten and your code will likely break.
115+
The actor `_runtime_ctx` variable is set to None. All the normal actor methods have been overwritten such as to not call it, but if your code itself interacts directly with `_runtime_ctx`, tests may fail.
116+
117+
The actor _state_manager is overwritten with an instance of `MockStateManager`. This has all the same methods and functionality of the base `ActorStateManager`, except for using the various `_mock` variables for storing data instead of the `_runtime_ctx`. If your code implements its own custom state manager it will be overwritten and tests will likely fail.
116118

117119
### Type Hinting
118120

0 commit comments

Comments
 (0)