|
33 | 33 | from .fake_dapr_server import FakeDaprSidecar |
34 | 34 | from dapr.conf import settings |
35 | 35 | from dapr.clients.grpc._helpers import to_bytes |
36 | | -from dapr.clients.grpc._request import TransactionalStateOperation |
| 36 | +from dapr.clients.grpc._request import TransactionalStateOperation, TransactionOperationType |
37 | 37 | from dapr.clients.grpc._state import StateOptions, Consistency, Concurrency, StateItem |
38 | 38 | from dapr.clients.grpc._crypto import EncryptOptions, DecryptOptions |
39 | 39 | from dapr.clients.grpc._response import ( |
@@ -508,6 +508,23 @@ def test_transaction_then_get_states(self): |
508 | 508 | self.assertEqual(resp.items[1].key, another_key) |
509 | 509 | self.assertEqual(resp.items[1].data, to_bytes(another_value.upper())) |
510 | 510 |
|
| 511 | + dapr.execute_state_transaction( |
| 512 | + store_name='statestore', |
| 513 | + operations=[ |
| 514 | + TransactionalStateOperation( |
| 515 | + key=key, operation_type=TransactionOperationType.delete |
| 516 | + ), |
| 517 | + TransactionalStateOperation( |
| 518 | + key=another_key, operation_type=TransactionOperationType.delete |
| 519 | + ), |
| 520 | + ], |
| 521 | + ) |
| 522 | + resp = dapr.get_state(store_name='statestore', key=key) |
| 523 | + self.assertEqual(resp.data, b'') |
| 524 | + |
| 525 | + resp = dapr.get_state(store_name='statestore', key=another_key) |
| 526 | + self.assertEqual(resp.data, b'') |
| 527 | + |
511 | 528 | self._fake_dapr_server.raise_exception_on_next_call( |
512 | 529 | status_pb2.Status(code=code_pb2.INVALID_ARGUMENT, message='my invalid argument message') |
513 | 530 | ) |
|
0 commit comments