Skip to content

Commit 46ccd74

Browse files
committed
Added test for deprecated function to increase coverage
Signed-off-by: Albert Callarisa <albert@diagrid.io>
1 parent 5e6d3c7 commit 46ccd74

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

tests/clients/test_dapr_grpc_client_async.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@
2929
from dapr.clients.grpc._crypto import DecryptOptions, EncryptOptions
3030
from dapr.clients.grpc._helpers import to_bytes
3131
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+
)
3336
from dapr.clients.grpc._response import (
3437
ConfigurationItem,
3538
ConfigurationResponse,
3639
ConfigurationWatcher,
3740
DaprResponse,
3841
UnlockResponseStatus,
42+
WorkflowRuntimeStatus,
3943
)
4044
from dapr.clients.grpc._state import Concurrency, Consistency, StateItem, StateOptions
4145
from dapr.common.pubsub.subscription import StreamInactiveError
@@ -565,6 +569,9 @@ async def test_transaction_then_get_states(self):
565569
operations=[
566570
TransactionalStateOperation(key=key, data=value, etag='foo'),
567571
TransactionalStateOperation(key=another_key, data=another_value),
572+
TransactionalStateOperation(
573+
key=key, operation_type=TransactionOperationType.delete
574+
),
568575
],
569576
transactional_metadata={'metakey': 'metavalue'},
570577
)
@@ -1763,6 +1770,38 @@ async def test_job_lifecycle(self):
17631770

17641771
await dapr.close()
17651772

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+
17661805

17671806
if __name__ == '__main__':
17681807
unittest.main()

0 commit comments

Comments
 (0)