|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 |
|
| 9 | +import temporalio.bridge.temporal_sdk_bridge |
9 | 10 | import temporalio.client |
10 | 11 | import temporalio.converter |
11 | 12 | import temporalio.worker |
@@ -177,6 +178,35 @@ async def test_worker_plugin_basic_config(client: Client) -> None: |
177 | 178 | ] |
178 | 179 |
|
179 | 180 |
|
| 181 | +async def test_worker_plugin_names_forwarded_to_core( |
| 182 | + client: Client, monkeypatch: pytest.MonkeyPatch |
| 183 | +) -> None: |
| 184 | + captured_plugins: list[str] = [] |
| 185 | + |
| 186 | + original_new_worker = temporalio.bridge.temporal_sdk_bridge.new_worker |
| 187 | + |
| 188 | + def new_worker_wrapper(runtime_ref, client_ref, config): |
| 189 | + nonlocal captured_plugins |
| 190 | + captured_plugins = list(config.plugins) |
| 191 | + return original_new_worker(runtime_ref, client_ref, config) |
| 192 | + |
| 193 | + monkeypatch.setattr( |
| 194 | + temporalio.bridge.temporal_sdk_bridge, |
| 195 | + "new_worker", |
| 196 | + new_worker_wrapper, |
| 197 | + ) |
| 198 | + |
| 199 | + plugin1 = SimplePlugin("test-worker-plugin1") |
| 200 | + plugin2 = SimplePlugin("test-worker-plugin2") |
| 201 | + worker = Worker( |
| 202 | + client, |
| 203 | + task_queue="queue", |
| 204 | + activities=[never_run_activity], |
| 205 | + plugins=[plugin1, plugin2], |
| 206 | + ) |
| 207 | + assert captured_plugins == [plugin1.name(), plugin2.name()] |
| 208 | + |
| 209 | + |
180 | 210 | async def test_worker_duplicated_plugin(client: Client) -> None: |
181 | 211 | new_config = client.config() |
182 | 212 | new_config["plugins"] = [MyCombinedPlugin()] |
|
0 commit comments