-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Description
Dialogflow has a page type that causes two of the generated unit tests to fail because of a name conflict.
gapic-generator-python/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2
Line 803 in b2e5274
| def test_{{ method.name|snake_case }}_pages(): |
def test_list_pages_pages():
client = PagesClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client._transport.list_pages), "__call__") as call:
# Set the response to a series of pages.
call.side_effect = (
page.ListPagesResponse( # page as a type
pages=[page.Page(), page.Page(), page.Page(),], next_page_token="abc",
),
page.ListPagesResponse(pages=[], next_page_token="def",),
page.ListPagesResponse(pages=[page.Page(),], next_page_token="ghi",),
page.ListPagesResponse(pages=[page.Page(), page.Page(),],),
RuntimeError,
)
pages = list(client.list_pages(request={}).pages)
for page, token in zip(pages, ["abc", "def", "ghi", ""]): # page used as local var
assert page.raw_page.next_page_token == token@pytest.mark.asyncio
async def test_list_pages_async_pages():
client = PagesAsyncClient(credentials=credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client._client._transport.list_pages),
"__call__",
new_callable=mock.AsyncMock,
) as call:
# Set the response to a series of pages.
call.side_effect = (
page.ListPagesResponse(
pages=[page.Page(), page.Page(), page.Page(),], next_page_token="abc",
),
page.ListPagesResponse(pages=[], next_page_token="def",),
page.ListPagesResponse(pages=[page.Page(),], next_page_token="ghi",),
page.ListPagesResponse(pages=[page.Page(), page.Page(),],),
RuntimeError,
)
pages = []
async for page in (await client.list_pages(request={})).pages:
pages.append(page)
for page, token in zip(pages, ["abc", "def", "ghi", ""]):
assert page.raw_page.next_page_token == tokenE UnboundLocalError: local variable 'page' referenced before assignment
tests/unit/gapic/dialogflowcx_v3beta1/test_pages.py:622: UnboundLocalError
Metadata
Metadata
Assignees
Labels
No labels