|
1 | 1 | """Test that CommandAwarePayloadVisitor handles all commands with seq fields that have payloads.""" |
2 | 2 |
|
| 3 | +from typing import Any, Iterator, Type |
| 4 | + |
3 | 5 | from temporalio.bridge._visitor import PayloadVisitor |
4 | | -from temporalio.worker._command_aware_visitor import ( |
5 | | - CommandAwarePayloadVisitor, |
6 | | - _get_workflow_activation_job_protos_with_seq, |
7 | | - _get_workflow_command_protos_with_seq, |
8 | | -) |
| 6 | +from temporalio.bridge.proto.workflow_activation import workflow_activation_pb2 |
| 7 | +from temporalio.bridge.proto.workflow_commands import workflow_commands_pb2 |
| 8 | +from temporalio.worker._command_aware_visitor import CommandAwarePayloadVisitor |
9 | 9 |
|
10 | 10 |
|
11 | 11 | def test_command_aware_visitor_has_methods_for_all_seq_protos_with_payloads(): |
@@ -73,3 +73,17 @@ def test_command_aware_visitor_has_methods_for_all_seq_protos_with_payloads(): |
73 | 73 | assert ( |
74 | 74 | len(jobs_with_payloads) == len(job_protos) - 1 |
75 | 75 | ), "Should have exactly one activation job without payloads (FireTimer)" |
| 76 | + |
| 77 | + |
| 78 | +def _get_workflow_command_protos_with_seq() -> Iterator[Type[Any]]: |
| 79 | + """Get concrete classes of all workflow command protos with a seq field.""" |
| 80 | + for descriptor in workflow_commands_pb2.DESCRIPTOR.message_types_by_name.values(): |
| 81 | + if "seq" in descriptor.fields_by_name: |
| 82 | + yield descriptor._concrete_class |
| 83 | + |
| 84 | + |
| 85 | +def _get_workflow_activation_job_protos_with_seq() -> Iterator[Type[Any]]: |
| 86 | + """Get concrete classes of all workflow activation job protos with a seq field.""" |
| 87 | + for descriptor in workflow_activation_pb2.DESCRIPTOR.message_types_by_name.values(): |
| 88 | + if "seq" in descriptor.fields_by_name: |
| 89 | + yield descriptor._concrete_class |
0 commit comments