1515#
1616import os
1717import re
18+ _UUID4_RE = re .compile (r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}" )
1819from unittest import mock
1920from unittest .mock import AsyncMock
2021
@@ -1863,7 +1864,7 @@ def test_create_job_non_empty_request_with_auto_populated_field():
18631864 call .assert_called ()
18641865 _ , args , _ = call .mock_calls [0 ]
18651866 # 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+ assert _UUID4_RE .match (args [0 ].request_id )
18671868 # clear UUID field so that the check below succeeds
18681869 args [0 ].request_id = None
18691870 assert args [0 ] == storage_batch_operations .CreateJobRequest (
@@ -2215,7 +2216,7 @@ def test_delete_job_non_empty_request_with_auto_populated_field():
22152216 call .assert_called ()
22162217 _ , args , _ = call .mock_calls [0 ]
22172218 # 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+ assert _UUID4_RE .match (args [0 ].request_id )
22192220 # clear UUID field so that the check below succeeds
22202221 args [0 ].request_id = None
22212222 assert args [0 ] == storage_batch_operations .DeleteJobRequest (
@@ -2533,7 +2534,7 @@ def test_cancel_job_non_empty_request_with_auto_populated_field():
25332534 call .assert_called ()
25342535 _ , args , _ = call .mock_calls [0 ]
25352536 # 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+ assert _UUID4_RE .match (args [0 ].request_id )
25372538 # clear UUID field so that the check below succeeds
25382539 args [0 ].request_id = None
25392540 assert args [0 ] == storage_batch_operations .CancelJobRequest (
@@ -4139,7 +4140,7 @@ def test_create_job_rest_required_fields(request_type=storage_batch_operations.C
41394140 found_field = None
41404141 for i , (key , value ) in enumerate (req .call_args .kwargs ['params' ]):
41414142 if key == "requestId" :
4142- 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}" , value )
4143+ assert _UUID4_RE .match (value )
41434144 found_field = i
41444145 break
41454146 if found_field is not None :
@@ -4318,7 +4319,7 @@ def test_delete_job_rest_required_fields(request_type=storage_batch_operations.D
43184319 found_field = None
43194320 for i , (key , value ) in enumerate (req .call_args .kwargs ['params' ]):
43204321 if key == "requestId" :
4321- 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}" , value )
4322+ assert _UUID4_RE .match (value )
43224323 found_field = i
43234324 break
43244325 if found_field is not None :
@@ -4495,7 +4496,7 @@ def test_cancel_job_rest_required_fields(request_type=storage_batch_operations.C
44954496 found_field = None
44964497 for i , (key , value ) in enumerate (req .call_args .kwargs ['params' ]):
44974498 if key == "requestId" :
4498- 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}" , value )
4499+ assert _UUID4_RE .match (value )
44994500 found_field = i
45004501 break
45014502 if found_field is not None :
@@ -5128,7 +5129,7 @@ def test_create_job_empty_call_grpc():
51285129 call .assert_called ()
51295130 _ , args , _ = call .mock_calls [0 ]
51305131 # Ensure that the uuid4 field is set according to AIP 4235
5131- 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 )
5132+ assert _UUID4_RE .match (args [0 ].request_id )
51325133 # clear UUID field so that the check below succeeds
51335134 args [0 ].request_id = None
51345135 request_msg = storage_batch_operations .CreateJobRequest ()
@@ -5155,7 +5156,7 @@ def test_delete_job_empty_call_grpc():
51555156 call .assert_called ()
51565157 _ , args , _ = call .mock_calls [0 ]
51575158 # Ensure that the uuid4 field is set according to AIP 4235
5158- 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 )
5159+ assert _UUID4_RE .match (args [0 ].request_id )
51595160 # clear UUID field so that the check below succeeds
51605161 args [0 ].request_id = None
51615162 request_msg = storage_batch_operations .DeleteJobRequest ()
@@ -5182,7 +5183,7 @@ def test_cancel_job_empty_call_grpc():
51825183 call .assert_called ()
51835184 _ , args , _ = call .mock_calls [0 ]
51845185 # Ensure that the uuid4 field is set according to AIP 4235
5185- 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 )
5186+ assert _UUID4_RE .match (args [0 ].request_id )
51865187 # clear UUID field so that the check below succeeds
51875188 args [0 ].request_id = None
51885189 request_msg = storage_batch_operations .CancelJobRequest ()
@@ -5333,7 +5334,7 @@ async def test_create_job_empty_call_grpc_asyncio():
53335334 call .assert_called ()
53345335 _ , args , _ = call .mock_calls [0 ]
53355336 # Ensure that the uuid4 field is set according to AIP 4235
5336- 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 )
5337+ assert _UUID4_RE .match (args [0 ].request_id )
53375338 # clear UUID field so that the check below succeeds
53385339 args [0 ].request_id = None
53395340 request_msg = storage_batch_operations .CreateJobRequest ()
@@ -5362,7 +5363,7 @@ async def test_delete_job_empty_call_grpc_asyncio():
53625363 call .assert_called ()
53635364 _ , args , _ = call .mock_calls [0 ]
53645365 # Ensure that the uuid4 field is set according to AIP 4235
5365- 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 )
5366+ assert _UUID4_RE .match (args [0 ].request_id )
53665367 # clear UUID field so that the check below succeeds
53675368 args [0 ].request_id = None
53685369 request_msg = storage_batch_operations .DeleteJobRequest ()
@@ -5392,7 +5393,7 @@ async def test_cancel_job_empty_call_grpc_asyncio():
53925393 call .assert_called ()
53935394 _ , args , _ = call .mock_calls [0 ]
53945395 # Ensure that the uuid4 field is set according to AIP 4235
5395- 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 )
5396+ assert _UUID4_RE .match (args [0 ].request_id )
53965397 # clear UUID field so that the check below succeeds
53975398 args [0 ].request_id = None
53985399 request_msg = storage_batch_operations .CancelJobRequest ()
@@ -6650,7 +6651,7 @@ def test_create_job_empty_call_rest():
66506651 call .assert_called ()
66516652 _ , args , _ = call .mock_calls [0 ]
66526653 # Ensure that the uuid4 field is set according to AIP 4235
6653- 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 )
6654+ assert _UUID4_RE .match (args [0 ].request_id )
66546655 # clear UUID field so that the check below succeeds
66556656 args [0 ].request_id = None
66566657 request_msg = storage_batch_operations .CreateJobRequest ()
@@ -6676,7 +6677,7 @@ def test_delete_job_empty_call_rest():
66766677 call .assert_called ()
66776678 _ , args , _ = call .mock_calls [0 ]
66786679 # Ensure that the uuid4 field is set according to AIP 4235
6679- 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 )
6680+ assert _UUID4_RE .match (args [0 ].request_id )
66806681 # clear UUID field so that the check below succeeds
66816682 args [0 ].request_id = None
66826683 request_msg = storage_batch_operations .DeleteJobRequest ()
@@ -6702,7 +6703,7 @@ def test_cancel_job_empty_call_rest():
67026703 call .assert_called ()
67036704 _ , args , _ = call .mock_calls [0 ]
67046705 # Ensure that the uuid4 field is set according to AIP 4235
6705- 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 )
6706+ assert _UUID4_RE .match (args [0 ].request_id )
67066707 # clear UUID field so that the check below succeeds
67076708 args [0 ].request_id = None
67086709 request_msg = storage_batch_operations .CancelJobRequest ()
0 commit comments