Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 654c7af

Browse files
committed
updates experimental fragments
1 parent a8c11b2 commit 654c7af

4 files changed

Lines changed: 128 additions & 3973 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
try:
2+
from unittest import mock
3+
from unittest.mock import AsyncMock # pragma: NO COVER
4+
except ImportError: # pragma: NO COVER
5+
import mock
6+
7+
from google.auth import credentials as ga_credentials
8+
9+
from google.fragment.services.max_results_dataset_service import MaxResultsDatasetServiceClient
10+
11+
from google.fragment.types import test_pagination_max_results_and_wrapper
12+
13+
# =========================================
14+
def test_list_my_dataset_w_max_results_set():
15+
client = MaxResultsDatasetServiceClient(
16+
credentials=ga_credentials.AnonymousCredentials(),
17+
transport='grpc',
18+
)
19+
20+
# Populate all string fields in the request which are not UUID4
21+
# since we want to check that UUID4 are populated automatically
22+
# if they meet the requirements of AIP 4235.
23+
request = test_pagination_max_results_and_wrapper.ListMaxResultsDatasetRequest(
24+
max_results=4,
25+
page_token='page_token_value',
26+
)
27+
28+
# Mock the actual call within the gRPC stub, and fake the request.
29+
with mock.patch.object(
30+
type(client.transport.list_max_results_dataset),
31+
'__call__') as call:
32+
33+
call.side_effect = (
34+
test_pagination_max_results_and_wrapper.ListMaxResultsDatasetResponse(
35+
datasets=[
36+
"a",
37+
"b",
38+
"c",
39+
"d",
40+
"e",
41+
],
42+
next_page_token='abc',
43+
),
44+
test_pagination_max_results_and_wrapper.ListMaxResultsDatasetResponse(
45+
datasets=[
46+
"f",
47+
],
48+
),
49+
)
50+
51+
52+
pager = client.list_max_results_dataset(request=request)
53+
results = list(pager)
54+
assert len(results) == 6
55+
assert all(isinstance(i, str)
56+
for i in results)
57+
58+
call.assert_called()
59+
_, args, _ = call.mock_calls[0]
60+
assert args[0] == test_pagination_max_results_and_wrapper.ListMaxResultsDatasetRequest(
61+
max_results=4,
62+
page_token='page_token_value',
63+
)
64+
# =========================================

0 commit comments

Comments
 (0)