Skip to content

Commit 26dcbf3

Browse files
committed
chore: replace re.match with re.fullmatch
1 parent 69a9623 commit 26dcbf3

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

packages/gapic-generator/gapic/ads-templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def test_{{ method_name }}_empty_call():
692692
{% if method_settings is not none %}
693693
{% for auto_populated_field in method_settings.auto_populated_fields %}
694694
# Ensure that the uuid4 field is set according to AIP 4235
695-
assert re.match(r"{{ uuid4_re }}", args[0].{{ auto_populated_field }})
695+
assert re.fullmatch(r"{{ uuid4_re }}", args[0].{{ auto_populated_field }})
696696
# clear UUID field so that the check below succeeds
697697
args[0].{{ auto_populated_field }} = None
698698
{% endfor %}
@@ -730,7 +730,7 @@ def test_{{ method_name }}_non_empty_request_with_auto_populated_field():
730730
{% if method_settings is not none %}
731731
{% for auto_populated_field in method_settings.auto_populated_fields %}
732732
# Ensure that the uuid4 field is set according to AIP 4235
733-
assert re.match(r"{{ uuid4_re }}", args[0].{{ auto_populated_field }})
733+
assert re.fullmatch(r"{{ uuid4_re }}", args[0].{{ auto_populated_field }})
734734
# clear UUID field so that the check below succeeds
735735
args[0].{{ auto_populated_field }} = None
736736
{% endfor %}

packages/gapic-generator/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_{{ method_name }}_non_empty_request_with_auto_populated_field():
151151
{% if method_settings is not none %}
152152
{% for auto_populated_field in method_settings.auto_populated_fields %}
153153
# Ensure that the uuid4 field is set according to AIP 4235
154-
assert re.match(r"{{ get_uuid4_re() }}", args[0].{{ auto_populated_field }})
154+
assert re.fullmatch(r"{{ get_uuid4_re() }}", args[0].{{ auto_populated_field }})
155155
# clear UUID field so that the check below succeeds
156156
args[0].{{ auto_populated_field }} = None
157157
{% endfor %}
@@ -1228,7 +1228,7 @@ def test_{{ method_name }}_rest_required_fields(request_type={{ method.input.ide
12281228
found_field = None
12291229
for i, (key, value) in enumerate(req.call_args.kwargs['params']):
12301230
if key == "{{ auto_populated_field|camel_case }}":
1231-
assert re.match(r"{{ get_uuid4_re() }}", value)
1231+
assert re.fullmatch(r"{{ get_uuid4_re() }}", value)
12321232
found_field = i
12331233
break
12341234
if found_field is not None:
@@ -1577,7 +1577,7 @@ def test_{{ method_name }}_rest_no_http_options():
15771577
{% if method_settings is not none %}
15781578
{% for auto_populated_field in method_settings.auto_populated_fields %}
15791579
# Ensure that the uuid4 field is set according to AIP 4235
1580-
assert re.match(r"{{ get_uuid4_re() }}", args[0].{{ auto_populated_field }})
1580+
assert re.fullmatch(r"{{ get_uuid4_re() }}", args[0].{{ auto_populated_field }})
15811581
# clear UUID field so that the check below succeeds
15821582
args[0].{{ auto_populated_field }} = None
15831583
{% endfor %}{# for auto_populated_field in method_settings.auto_populated_fields #}

packages/gapic-generator/tests/integration/goldens/storagebatchoperations/tests/unit/gapic/storagebatchoperations_v1/test_storage_batch_operations.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ def test_create_job_non_empty_request_with_auto_populated_field():
18631863
call.assert_called()
18641864
_, args, _ = call.mock_calls[0]
18651865
# 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)
1866+
assert re.fullmatch(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)
18671867
# clear UUID field so that the check below succeeds
18681868
args[0].request_id = None
18691869
assert args[0] == storage_batch_operations.CreateJobRequest(
@@ -2215,7 +2215,7 @@ def test_delete_job_non_empty_request_with_auto_populated_field():
22152215
call.assert_called()
22162216
_, args, _ = call.mock_calls[0]
22172217
# 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)
2218+
assert re.fullmatch(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)
22192219
# clear UUID field so that the check below succeeds
22202220
args[0].request_id = None
22212221
assert args[0] == storage_batch_operations.DeleteJobRequest(
@@ -2533,7 +2533,7 @@ def test_cancel_job_non_empty_request_with_auto_populated_field():
25332533
call.assert_called()
25342534
_, args, _ = call.mock_calls[0]
25352535
# 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)
2536+
assert re.fullmatch(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)
25372537
# clear UUID field so that the check below succeeds
25382538
args[0].request_id = None
25392539
assert args[0] == storage_batch_operations.CancelJobRequest(
@@ -4139,7 +4139,7 @@ def test_create_job_rest_required_fields(request_type=storage_batch_operations.C
41394139
found_field = None
41404140
for i, (key, value) in enumerate(req.call_args.kwargs['params']):
41414141
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)
4142+
assert re.fullmatch(r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}", value)
41434143
found_field = i
41444144
break
41454145
if found_field is not None:
@@ -4318,7 +4318,7 @@ def test_delete_job_rest_required_fields(request_type=storage_batch_operations.D
43184318
found_field = None
43194319
for i, (key, value) in enumerate(req.call_args.kwargs['params']):
43204320
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)
4321+
assert re.fullmatch(r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}", value)
43224322
found_field = i
43234323
break
43244324
if found_field is not None:
@@ -4495,7 +4495,7 @@ def test_cancel_job_rest_required_fields(request_type=storage_batch_operations.C
44954495
found_field = None
44964496
for i, (key, value) in enumerate(req.call_args.kwargs['params']):
44974497
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)
4498+
assert re.fullmatch(r"[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}", value)
44994499
found_field = i
45004500
break
45014501
if found_field is not None:
@@ -5128,7 +5128,7 @@ def test_create_job_empty_call_grpc():
51285128
call.assert_called()
51295129
_, args, _ = call.mock_calls[0]
51305130
# 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)
5131+
assert re.fullmatch(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)
51325132
# clear UUID field so that the check below succeeds
51335133
args[0].request_id = None
51345134
request_msg = storage_batch_operations.CreateJobRequest()
@@ -5155,7 +5155,7 @@ def test_delete_job_empty_call_grpc():
51555155
call.assert_called()
51565156
_, args, _ = call.mock_calls[0]
51575157
# 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)
5158+
assert re.fullmatch(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)
51595159
# clear UUID field so that the check below succeeds
51605160
args[0].request_id = None
51615161
request_msg = storage_batch_operations.DeleteJobRequest()
@@ -5182,7 +5182,7 @@ def test_cancel_job_empty_call_grpc():
51825182
call.assert_called()
51835183
_, args, _ = call.mock_calls[0]
51845184
# 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)
5185+
assert re.fullmatch(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)
51865186
# clear UUID field so that the check below succeeds
51875187
args[0].request_id = None
51885188
request_msg = storage_batch_operations.CancelJobRequest()
@@ -5333,7 +5333,7 @@ async def test_create_job_empty_call_grpc_asyncio():
53335333
call.assert_called()
53345334
_, args, _ = call.mock_calls[0]
53355335
# 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)
5336+
assert re.fullmatch(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)
53375337
# clear UUID field so that the check below succeeds
53385338
args[0].request_id = None
53395339
request_msg = storage_batch_operations.CreateJobRequest()
@@ -5362,7 +5362,7 @@ async def test_delete_job_empty_call_grpc_asyncio():
53625362
call.assert_called()
53635363
_, args, _ = call.mock_calls[0]
53645364
# 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)
5365+
assert re.fullmatch(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)
53665366
# clear UUID field so that the check below succeeds
53675367
args[0].request_id = None
53685368
request_msg = storage_batch_operations.DeleteJobRequest()
@@ -5392,7 +5392,7 @@ async def test_cancel_job_empty_call_grpc_asyncio():
53925392
call.assert_called()
53935393
_, args, _ = call.mock_calls[0]
53945394
# 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)
5395+
assert re.fullmatch(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)
53965396
# clear UUID field so that the check below succeeds
53975397
args[0].request_id = None
53985398
request_msg = storage_batch_operations.CancelJobRequest()
@@ -6650,7 +6650,7 @@ def test_create_job_empty_call_rest():
66506650
call.assert_called()
66516651
_, args, _ = call.mock_calls[0]
66526652
# 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)
6653+
assert re.fullmatch(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)
66546654
# clear UUID field so that the check below succeeds
66556655
args[0].request_id = None
66566656
request_msg = storage_batch_operations.CreateJobRequest()
@@ -6676,7 +6676,7 @@ def test_delete_job_empty_call_rest():
66766676
call.assert_called()
66776677
_, args, _ = call.mock_calls[0]
66786678
# 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)
6679+
assert re.fullmatch(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)
66806680
# clear UUID field so that the check below succeeds
66816681
args[0].request_id = None
66826682
request_msg = storage_batch_operations.DeleteJobRequest()
@@ -6702,7 +6702,7 @@ def test_cancel_job_empty_call_rest():
67026702
call.assert_called()
67036703
_, args, _ = call.mock_calls[0]
67046704
# 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)
6705+
assert re.fullmatch(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)
67066706
# clear UUID field so that the check below succeeds
67076707
args[0].request_id = None
67086708
request_msg = storage_batch_operations.CancelJobRequest()

0 commit comments

Comments
 (0)