Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: revert "fix: do not error on LROs with no response or error"#294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gcf-merge-on-green merged 2 commits intomainfromrevert-258-fix-empty-LROs
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletionsgoogle/api_core/operation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,11 +140,11 @@ def _set_result_from_operation(self):
)
self.set_exception(exception)
else:
# Some APIs set `done: true`, with an empty response.
# Set the result to an empty message of the expected
# result type.
# https://google.aip.dev/151
self.set_result(self._result_type())
exception = exceptions.GoogleAPICallError(
"Unexpected state: Long-running operation had neither "
"response nor error set."
)
self.set_exception(exception)

def _refresh_and_update(self, retry=polling.DEFAULT_RETRY):
"""Refresh the operation and update the result if needed.
Expand Down
10 changes: 5 additions & 5 deletionsgoogle/api_core/operation_async.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -136,11 +136,11 @@ def _set_result_from_operation(self):
)
self.set_exception(exception)
else:
# Some APIs set `done: true`, with an empty response.
# Set the result to an empty message of the expected
# result type.
# https://google.aip.dev/151
self.set_result(self._result_type())
exception = exceptions.GoogleAPICallError(
"Unexpected state: Long-running operation had neither "
"response nor error set."
)
self.set_exception(exception)

async def _refresh_and_update(self, retry=async_future.DEFAULT_RETRY):
"""Refresh the operation and update the result if needed.
Expand Down
6 changes: 3 additions & 3 deletionstests/asyncio/test_operation_async.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -158,17 +158,17 @@ async def test_exception():

@mock.patch("asyncio.sleep", autospec=True)
@pytest.mark.asyncio
async deftest_done_with_no_error_or_response(unused_sleep):
async deftest_unexpected_result(unused_sleep):
responses = [
make_operation_proto(),
# Second operation response is done, but has not error or response.
make_operation_proto(done=True),
]
future, _, _ = make_operation_future(responses)

result = await future.result()
exception = await future.exception()

assertisinstance(result, struct_pb2.Struct)
assert"Unexpected state" in "{!r}".format(exception)


def test_from_gapic():
Expand Down
6 changes: 4 additions & 2 deletionstests/unit/test_operation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -169,15 +169,17 @@ def test_exception_with_error_code():
assert isinstance(exception, exceptions.NotFound)


deftest_done_with_no_error_or_response():
deftest_unexpected_result():
responses = [
make_operation_proto(),
# Second operation response is done, but has not error or response.
make_operation_proto(done=True),
]
future, _, _ = make_operation_future(responses)

assert isinstance(future.result(), struct_pb2.Struct)
exception = future.exception()

assert "Unexpected state" in "{!r}".format(exception)


def test__refresh_http():
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp