File tree 4 files changed +17
-15
lines changed
4 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -140,11 +140,11 @@ def _set_result_from_operation(self):
140
140
)
141
141
self .set_exception (exception )
142
142
else :
143
- # Some APIs set `done: true`, with an empty response.
144
- # Set the result to an empty message of the expected
145
- # result type.
146
- # https://google.aip.dev/151
147
- self .set_result ( self . _result_type () )
143
+ exception = exceptions . GoogleAPICallError (
144
+ "Unexpected state: Long-running operation had neither "
145
+ "response nor error set."
146
+ )
147
+ self .set_exception ( exception )
148
148
149
149
def _refresh_and_update (self , retry = polling .DEFAULT_RETRY ):
150
150
"""Refresh the operation and update the result if needed.
Original file line number Diff line number Diff line change @@ -136,11 +136,11 @@ def _set_result_from_operation(self):
136
136
)
137
137
self .set_exception (exception )
138
138
else :
139
- # Some APIs set `done: true`, with an empty response.
140
- # Set the result to an empty message of the expected
141
- # result type.
142
- # https://google.aip.dev/151
143
- self .set_result ( self . _result_type () )
139
+ exception = exceptions . GoogleAPICallError (
140
+ "Unexpected state: Long-running operation had neither "
141
+ "response nor error set."
142
+ )
143
+ self .set_exception ( exception )
144
144
145
145
async def _refresh_and_update (self , retry = async_future .DEFAULT_RETRY ):
146
146
"""Refresh the operation and update the result if needed.
Original file line number Diff line number Diff line change @@ -158,17 +158,17 @@ async def test_exception():
158
158
159
159
@mock .patch ("asyncio.sleep" , autospec = True )
160
160
@pytest .mark .asyncio
161
- async def test_done_with_no_error_or_response (unused_sleep ):
161
+ async def test_unexpected_result (unused_sleep ):
162
162
responses = [
163
163
make_operation_proto (),
164
164
# Second operation response is done, but has not error or response.
165
165
make_operation_proto (done = True ),
166
166
]
167
167
future , _ , _ = make_operation_future (responses )
168
168
169
- result = await future .result ()
169
+ exception = await future .exception ()
170
170
171
- assert isinstance ( result , struct_pb2 . Struct )
171
+ assert "Unexpected state" in "{!r}" . format ( exception )
172
172
173
173
174
174
def test_from_gapic ():
Original file line number Diff line number Diff line change @@ -169,15 +169,17 @@ def test_exception_with_error_code():
169
169
assert isinstance (exception , exceptions .NotFound )
170
170
171
171
172
- def test_done_with_no_error_or_response ():
172
+ def test_unexpected_result ():
173
173
responses = [
174
174
make_operation_proto (),
175
175
# Second operation response is done, but has not error or response.
176
176
make_operation_proto (done = True ),
177
177
]
178
178
future , _ , _ = make_operation_future (responses )
179
179
180
- assert isinstance (future .result (), struct_pb2 .Struct )
180
+ exception = future .exception ()
181
+
182
+ assert "Unexpected state" in "{!r}" .format (exception )
181
183
182
184
183
185
def test__refresh_http ():
You can’t perform that action at this time.
0 commit comments