|
29 | 29 | from dapr.clients.grpc._crypto import DecryptOptions, EncryptOptions |
30 | 30 | from dapr.clients.grpc._helpers import to_bytes |
31 | 31 | from dapr.clients.grpc._jobs import Job |
32 | | -from dapr.clients.grpc._request import TransactionalStateOperation |
| 32 | +from dapr.clients.grpc._request import ( |
| 33 | + TransactionalStateOperation, |
| 34 | + TransactionOperationType, |
| 35 | +) |
33 | 36 | from dapr.clients.grpc._response import ( |
34 | 37 | ConfigurationItem, |
35 | 38 | ConfigurationResponse, |
36 | 39 | ConfigurationWatcher, |
37 | 40 | DaprResponse, |
38 | 41 | UnlockResponseStatus, |
| 42 | + WorkflowRuntimeStatus, |
39 | 43 | ) |
40 | 44 | from dapr.clients.grpc._state import Concurrency, Consistency, StateItem, StateOptions |
41 | 45 | from dapr.common.pubsub.subscription import StreamInactiveError |
@@ -565,6 +569,9 @@ async def test_transaction_then_get_states(self): |
565 | 569 | operations=[ |
566 | 570 | TransactionalStateOperation(key=key, data=value, etag='foo'), |
567 | 571 | TransactionalStateOperation(key=another_key, data=another_value), |
| 572 | + TransactionalStateOperation( |
| 573 | + key=key, operation_type=TransactionOperationType.delete |
| 574 | + ), |
568 | 575 | ], |
569 | 576 | transactional_metadata={'metakey': 'metavalue'}, |
570 | 577 | ) |
@@ -1763,6 +1770,38 @@ async def test_job_lifecycle(self): |
1763 | 1770 |
|
1764 | 1771 | await dapr.close() |
1765 | 1772 |
|
| 1773 | + async def test_workflow_deprecated(self): |
| 1774 | + dapr = DaprGrpcClientAsync(f'{self.scheme}localhost:{self.grpc_port}') |
| 1775 | + workflow_name = 'test_workflow' |
| 1776 | + event_name = 'eventName' |
| 1777 | + instance_id = str(uuid.uuid4()) |
| 1778 | + workflow_component = 'dapr' |
| 1779 | + input = 'paperclips' |
| 1780 | + event_data = 'cars' |
| 1781 | + |
| 1782 | + # Start the workflow |
| 1783 | + start_response = await dapr.start_workflow( |
| 1784 | + instance_id=instance_id, |
| 1785 | + workflow_name=workflow_name, |
| 1786 | + workflow_component=workflow_component, |
| 1787 | + input=input, |
| 1788 | + workflow_options=None, |
| 1789 | + ) |
| 1790 | + self.assertEqual(instance_id, start_response.instance_id) |
| 1791 | + |
| 1792 | + # Get info on the workflow to check that it is running |
| 1793 | + get_response = await dapr.get_workflow( |
| 1794 | + instance_id=instance_id, workflow_component=workflow_component |
| 1795 | + ) |
| 1796 | + self.assertEqual(WorkflowRuntimeStatus.RUNNING.value, get_response.runtime_status) |
| 1797 | + |
| 1798 | + # Raise an event on the workflow. |
| 1799 | + await dapr.raise_workflow_event(instance_id, workflow_component, event_name, event_data) |
| 1800 | + get_response = await dapr.get_workflow(instance_id, workflow_component) |
| 1801 | + self.assertEqual(event_data, get_response.properties[instance_id].strip('""')) |
| 1802 | + |
| 1803 | + await dapr.close() |
| 1804 | + |
1766 | 1805 |
|
1767 | 1806 | if __name__ == '__main__': |
1768 | 1807 | unittest.main() |
0 commit comments