1414# limitations under the License.
1515#
1616import os
17+ import re
1718from unittest import mock
1819from unittest .mock import AsyncMock
1920
@@ -1813,6 +1814,10 @@ def test_create_job(request_type, transport: str = 'grpc'):
18131814 # Everything is optional in proto3 as far as the runtime is concerned,
18141815 # and we are mocking out the actual API, so just send an empty request.
18151816 request = request_type ()
1817+ if isinstance (request , dict ):
1818+ request ['request_id' ] = "explicit value for autopopulate-able field"
1819+ else :
1820+ request .request_id = "explicit value for autopopulate-able field"
18161821
18171822 # Mock the actual call within the gRPC stub, and fake the request.
18181823 with mock .patch .object (
@@ -1826,6 +1831,7 @@ def test_create_job(request_type, transport: str = 'grpc'):
18261831 assert len (call .mock_calls ) == 1
18271832 _ , args , _ = call .mock_calls [0 ]
18281833 request = storage_batch_operations .CreateJobRequest ()
1834+ request .request_id = "explicit value for autopopulate-able field"
18291835 assert args [0 ] == request
18301836
18311837 # Establish that the response is the type that we expect.
@@ -1856,6 +1862,10 @@ def test_create_job_non_empty_request_with_auto_populated_field():
18561862 client .create_job (request = request )
18571863 call .assert_called ()
18581864 _ , args , _ = call .mock_calls [0 ]
1865+ # Ensure that the uuid4 field is set according to AIP 4235
1866+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
1867+ # clear UUID field so that the check below succeeds
1868+ args [0 ].request_id = None
18591869 assert args [0 ] == storage_batch_operations .CreateJobRequest (
18601870 parent = 'parent_value' ,
18611871 job_id = 'job_id_value' ,
@@ -1947,6 +1957,10 @@ async def test_create_job_async(transport: str = 'grpc_asyncio', request_type=st
19471957 # Everything is optional in proto3 as far as the runtime is concerned,
19481958 # and we are mocking out the actual API, so just send an empty request.
19491959 request = request_type ()
1960+ if isinstance (request , dict ):
1961+ request ['request_id' ] = "explicit value for autopopulate-able field"
1962+ else :
1963+ request .request_id = "explicit value for autopopulate-able field"
19501964
19511965 # Mock the actual call within the gRPC stub, and fake the request.
19521966 with mock .patch .object (
@@ -1962,6 +1976,7 @@ async def test_create_job_async(transport: str = 'grpc_asyncio', request_type=st
19621976 assert len (call .mock_calls )
19631977 _ , args , _ = call .mock_calls [0 ]
19641978 request = storage_batch_operations .CreateJobRequest ()
1979+ request .request_id = "explicit value for autopopulate-able field"
19651980 assert args [0 ] == request
19661981
19671982 # Establish that the response is the type that we expect.
@@ -2152,6 +2167,10 @@ def test_delete_job(request_type, transport: str = 'grpc'):
21522167 # Everything is optional in proto3 as far as the runtime is concerned,
21532168 # and we are mocking out the actual API, so just send an empty request.
21542169 request = request_type ()
2170+ if isinstance (request , dict ):
2171+ request ['request_id' ] = "explicit value for autopopulate-able field"
2172+ else :
2173+ request .request_id = "explicit value for autopopulate-able field"
21552174
21562175 # Mock the actual call within the gRPC stub, and fake the request.
21572176 with mock .patch .object (
@@ -2165,6 +2184,7 @@ def test_delete_job(request_type, transport: str = 'grpc'):
21652184 assert len (call .mock_calls ) == 1
21662185 _ , args , _ = call .mock_calls [0 ]
21672186 request = storage_batch_operations .DeleteJobRequest ()
2187+ request .request_id = "explicit value for autopopulate-able field"
21682188 assert args [0 ] == request
21692189
21702190 # Establish that the response is the type that we expect.
@@ -2194,6 +2214,10 @@ def test_delete_job_non_empty_request_with_auto_populated_field():
21942214 client .delete_job (request = request )
21952215 call .assert_called ()
21962216 _ , args , _ = call .mock_calls [0 ]
2217+ # Ensure that the uuid4 field is set according to AIP 4235
2218+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
2219+ # clear UUID field so that the check below succeeds
2220+ args [0 ].request_id = None
21972221 assert args [0 ] == storage_batch_operations .DeleteJobRequest (
21982222 name = 'name_value' ,
21992223 )
@@ -2274,6 +2298,10 @@ async def test_delete_job_async(transport: str = 'grpc_asyncio', request_type=st
22742298 # Everything is optional in proto3 as far as the runtime is concerned,
22752299 # and we are mocking out the actual API, so just send an empty request.
22762300 request = request_type ()
2301+ if isinstance (request , dict ):
2302+ request ['request_id' ] = "explicit value for autopopulate-able field"
2303+ else :
2304+ request .request_id = "explicit value for autopopulate-able field"
22772305
22782306 # Mock the actual call within the gRPC stub, and fake the request.
22792307 with mock .patch .object (
@@ -2287,6 +2315,7 @@ async def test_delete_job_async(transport: str = 'grpc_asyncio', request_type=st
22872315 assert len (call .mock_calls )
22882316 _ , args , _ = call .mock_calls [0 ]
22892317 request = storage_batch_operations .DeleteJobRequest ()
2318+ request .request_id = "explicit value for autopopulate-able field"
22902319 assert args [0 ] == request
22912320
22922321 # Establish that the response is the type that we expect.
@@ -2455,6 +2484,10 @@ def test_cancel_job(request_type, transport: str = 'grpc'):
24552484 # Everything is optional in proto3 as far as the runtime is concerned,
24562485 # and we are mocking out the actual API, so just send an empty request.
24572486 request = request_type ()
2487+ if isinstance (request , dict ):
2488+ request ['request_id' ] = "explicit value for autopopulate-able field"
2489+ else :
2490+ request .request_id = "explicit value for autopopulate-able field"
24582491
24592492 # Mock the actual call within the gRPC stub, and fake the request.
24602493 with mock .patch .object (
@@ -2469,6 +2502,7 @@ def test_cancel_job(request_type, transport: str = 'grpc'):
24692502 assert len (call .mock_calls ) == 1
24702503 _ , args , _ = call .mock_calls [0 ]
24712504 request = storage_batch_operations .CancelJobRequest ()
2505+ request .request_id = "explicit value for autopopulate-able field"
24722506 assert args [0 ] == request
24732507
24742508 # Establish that the response is the type that we expect.
@@ -2498,6 +2532,10 @@ def test_cancel_job_non_empty_request_with_auto_populated_field():
24982532 client .cancel_job (request = request )
24992533 call .assert_called ()
25002534 _ , args , _ = call .mock_calls [0 ]
2535+ # Ensure that the uuid4 field is set according to AIP 4235
2536+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
2537+ # clear UUID field so that the check below succeeds
2538+ args [0 ].request_id = None
25012539 assert args [0 ] == storage_batch_operations .CancelJobRequest (
25022540 name = 'name_value' ,
25032541 )
@@ -2578,6 +2616,10 @@ async def test_cancel_job_async(transport: str = 'grpc_asyncio', request_type=st
25782616 # Everything is optional in proto3 as far as the runtime is concerned,
25792617 # and we are mocking out the actual API, so just send an empty request.
25802618 request = request_type ()
2619+ if isinstance (request , dict ):
2620+ request ['request_id' ] = "explicit value for autopopulate-able field"
2621+ else :
2622+ request .request_id = "explicit value for autopopulate-able field"
25812623
25822624 # Mock the actual call within the gRPC stub, and fake the request.
25832625 with mock .patch .object (
@@ -2592,6 +2634,7 @@ async def test_cancel_job_async(transport: str = 'grpc_asyncio', request_type=st
25922634 assert len (call .mock_calls )
25932635 _ , args , _ = call .mock_calls [0 ]
25942636 request = storage_batch_operations .CancelJobRequest ()
2637+ request .request_id = "explicit value for autopopulate-able field"
25952638 assert args [0 ] == request
25962639
25972640 # Establish that the response is the type that we expect.
@@ -5048,6 +5091,10 @@ def test_create_job_empty_call_grpc():
50485091 # Establish that the underlying stub method was called.
50495092 call .assert_called ()
50505093 _ , args , _ = call .mock_calls [0 ]
5094+ # Ensure that the uuid4 field is set according to AIP 4235
5095+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
5096+ # clear UUID field so that the check below succeeds
5097+ args [0 ].request_id = None
50515098 request_msg = storage_batch_operations .CreateJobRequest ()
50525099
50535100 assert args [0 ] == request_msg
@@ -5071,6 +5118,10 @@ def test_delete_job_empty_call_grpc():
50715118 # Establish that the underlying stub method was called.
50725119 call .assert_called ()
50735120 _ , args , _ = call .mock_calls [0 ]
5121+ # Ensure that the uuid4 field is set according to AIP 4235
5122+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
5123+ # clear UUID field so that the check below succeeds
5124+ args [0 ].request_id = None
50745125 request_msg = storage_batch_operations .DeleteJobRequest ()
50755126
50765127 assert args [0 ] == request_msg
@@ -5094,6 +5145,10 @@ def test_cancel_job_empty_call_grpc():
50945145 # Establish that the underlying stub method was called.
50955146 call .assert_called ()
50965147 _ , args , _ = call .mock_calls [0 ]
5148+ # Ensure that the uuid4 field is set according to AIP 4235
5149+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
5150+ # clear UUID field so that the check below succeeds
5151+ args [0 ].request_id = None
50975152 request_msg = storage_batch_operations .CancelJobRequest ()
50985153
50995154 assert args [0 ] == request_msg
@@ -5241,6 +5296,10 @@ async def test_create_job_empty_call_grpc_asyncio():
52415296 # Establish that the underlying stub method was called.
52425297 call .assert_called ()
52435298 _ , args , _ = call .mock_calls [0 ]
5299+ # Ensure that the uuid4 field is set according to AIP 4235
5300+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
5301+ # clear UUID field so that the check below succeeds
5302+ args [0 ].request_id = None
52445303 request_msg = storage_batch_operations .CreateJobRequest ()
52455304
52465305 assert args [0 ] == request_msg
@@ -5266,6 +5325,10 @@ async def test_delete_job_empty_call_grpc_asyncio():
52665325 # Establish that the underlying stub method was called.
52675326 call .assert_called ()
52685327 _ , args , _ = call .mock_calls [0 ]
5328+ # Ensure that the uuid4 field is set according to AIP 4235
5329+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
5330+ # clear UUID field so that the check below succeeds
5331+ args [0 ].request_id = None
52695332 request_msg = storage_batch_operations .DeleteJobRequest ()
52705333
52715334 assert args [0 ] == request_msg
@@ -5292,6 +5355,10 @@ async def test_cancel_job_empty_call_grpc_asyncio():
52925355 # Establish that the underlying stub method was called.
52935356 call .assert_called ()
52945357 _ , args , _ = call .mock_calls [0 ]
5358+ # Ensure that the uuid4 field is set according to AIP 4235
5359+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
5360+ # clear UUID field so that the check below succeeds
5361+ args [0 ].request_id = None
52955362 request_msg = storage_batch_operations .CancelJobRequest ()
52965363
52975364 assert args [0 ] == request_msg
@@ -6546,6 +6613,10 @@ def test_create_job_empty_call_rest():
65466613 # Establish that the underlying stub method was called.
65476614 call .assert_called ()
65486615 _ , args , _ = call .mock_calls [0 ]
6616+ # Ensure that the uuid4 field is set according to AIP 4235
6617+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
6618+ # clear UUID field so that the check below succeeds
6619+ args [0 ].request_id = None
65496620 request_msg = storage_batch_operations .CreateJobRequest ()
65506621
65516622 assert args [0 ] == request_msg
@@ -6568,6 +6639,10 @@ def test_delete_job_empty_call_rest():
65686639 # Establish that the underlying stub method was called.
65696640 call .assert_called ()
65706641 _ , args , _ = call .mock_calls [0 ]
6642+ # Ensure that the uuid4 field is set according to AIP 4235
6643+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
6644+ # clear UUID field so that the check below succeeds
6645+ args [0 ].request_id = None
65716646 request_msg = storage_batch_operations .DeleteJobRequest ()
65726647
65736648 assert args [0 ] == request_msg
@@ -6590,6 +6665,10 @@ def test_cancel_job_empty_call_rest():
65906665 # Establish that the underlying stub method was called.
65916666 call .assert_called ()
65926667 _ , args , _ = call .mock_calls [0 ]
6668+ # Ensure that the uuid4 field is set according to AIP 4235
6669+ assert re .match (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" , args [0 ].request_id )
6670+ # clear UUID field so that the check below succeeds
6671+ args [0 ].request_id = None
65936672 request_msg = storage_batch_operations .CancelJobRequest ()
65946673
65956674 assert args [0 ] == request_msg
0 commit comments