Skip to content

Commit

Permalink
fix: Fix coverage gap in tests (#1802)
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Oct 16, 2023
1 parent 71fe4b4 commit 2fe0df1
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,8 @@ def test_{{ method.name|snake_case }}_rest(request_type):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -1044,8 +1045,8 @@ def test_{{ method.name|snake_case }}_rest(request_type):

subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["{{ field.name }}"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["{{ field.name }}"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -1064,7 +1065,8 @@ def test_{{ method.name|snake_case }}_rest(request_type):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,8 @@ def test_{{ method_name }}_rest(request_type):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -918,7 +919,8 @@ def test_{{ method_name }}_rest(request_type):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["{{ field.name }}"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["{{ field.name }}"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -937,7 +939,8 @@ def test_{{ method_name }}_rest(request_type):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10011,7 +10011,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -10024,7 +10025,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["saved_query"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["saved_query"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -10043,7 +10045,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down Expand Up @@ -10864,7 +10867,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -10877,7 +10881,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["saved_query"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["saved_query"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -10896,7 +10901,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6243,7 +6243,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -6256,7 +6257,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["trigger"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["trigger"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -6275,7 +6277,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down Expand Up @@ -6559,7 +6562,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -6572,7 +6576,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["trigger"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["trigger"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -6591,7 +6596,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down Expand Up @@ -7641,7 +7647,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -7654,7 +7661,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["channel"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["channel"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -7673,7 +7681,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down Expand Up @@ -7957,7 +7966,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -7970,7 +7980,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["channel"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["channel"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -7989,7 +8000,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down Expand Up @@ -9561,7 +9573,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -9574,7 +9587,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["channel_connection"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["channel_connection"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -9593,7 +9607,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down Expand Up @@ -10329,7 +10344,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -10342,7 +10358,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["google_channel_config"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["google_channel_config"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -10361,7 +10378,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4320,7 +4320,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -4333,7 +4334,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["instance"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["instance"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -4352,7 +4354,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down Expand Up @@ -4625,7 +4628,8 @@ def get_message_fields(field):

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
else:
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

Expand All @@ -4638,7 +4642,8 @@ def get_message_fields(field):
subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
for field, value in request_init["instance"].items():
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["instance"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
Expand All @@ -4657,7 +4662,8 @@ def get_message_fields(field):
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
for subfield_to_delete in subfields_not_in_runtime:
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
Expand Down

0 comments on commit 2fe0df1

Please sign in to comment.