Skip to content
11 changes: 9 additions & 2 deletions tests/functional/botocore/test_h2_required.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def _all_test_cases():
@pytest.mark.parametrize("h2_service", H2_SERVICES)
def test_all_uses_of_h2_are_known(h2_service):
# Validates that a service that requires HTTP 2 for all operations is known
message = f'Found unknown HTTP 2 service: {h2_service}'
message = (
f'Found unknown HTTP 2 service: {h2_service}\n'
f'Target={h2_service}'
)
assert _KNOWN_SERVICES.get(h2_service) is _H2_REQUIRED, message


Expand All @@ -64,5 +67,9 @@ def test_all_uses_of_h2_are_known(h2_service):
def test_all_h2_operations_are_known(h2_service, operation):
# Validates that an operation that requires HTTP 2 is known
known_operations = _KNOWN_SERVICES.get(h2_service, [])
message = f'Found unknown HTTP 2 operation: {h2_service}.{operation}'
message = (
f'Found unknown HTTP 2 operation: {h2_service}.{operation}\n'
f"Target={h2_service}.{operation}"
)

assert operation in known_operations, message
53 changes: 28 additions & 25 deletions tests/functional/botocore/test_paginator_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,36 +150,39 @@ def _pagination_configs():
"operation_name, page_config, service_model", _pagination_configs()
)
def test_lint_pagination_configs(operation_name, page_config, service_model):
_validate_known_pagination_keys(page_config)
_validate_result_key_exists(page_config)
_validate_known_pagination_keys(operation_name, page_config)
_validate_result_key_exists(operation_name, page_config)
_validate_referenced_operation_exists(operation_name, service_model)
_validate_operation_has_output(operation_name, service_model)
_validate_input_keys_match(operation_name, page_config, service_model)
_validate_output_keys_match(operation_name, page_config, service_model)
_validate_new_numeric_keys(operation_name, page_config, service_model)


def _validate_known_pagination_keys(page_config):
def _validate_known_pagination_keys(operation_name, page_config):
for key in page_config:
if key not in KNOWN_PAGE_KEYS:
raise AssertionError(
f"Unknown key '{key}' in pagination config: {page_config}"
f"Unknown key '{key}' in pagination config: {page_config}\n"
f"Target={operation_name}.{key}"
)


def _validate_result_key_exists(page_config):
def _validate_result_key_exists(operation_name, page_config):
if 'result_key' not in page_config:
raise AssertionError(
"Required key 'result_key' is missing "
f"from pagination config: {page_config}"
f"from pagination config: {page_config}\n"
f"Target={operation_name}.result_key"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the word "Target" doing here and in all of the below examples? This is functional, but it doesn't seem relevant to the public facing tests.

)


def _validate_referenced_operation_exists(operation_name, service_model):
if operation_name not in service_model.operation_names:
raise AssertionError(
"Pagination config refers to operation that "
f"does not exist: {operation_name}"
f"does not exist: {operation_name}\n"
f"Target={operation_name}"
)


Expand All @@ -189,7 +192,8 @@ def _validate_operation_has_output(operation_name, service_model):
if output is None or not output.members:
raise AssertionError(
"Pagination config refers to operation "
f"that does not have any output: {operation_name}"
f"that does not have any output: {operation_name}\n"
f"Target={operation_name}"
)


Expand All @@ -203,20 +207,19 @@ def _validate_input_keys_match(operation_name, page_config, service_model):
for token in input_tokens:
if token not in valid_input_names:
raise AssertionError(
f"input_token '{token}' refers to a non existent "
f"input member for operation: {operation_name}"
f"input_token refers to a non existent "
f"input member for operation.\n"
f"Target={operation_name}.{token}"
)
if 'limit_key' in page_config:
limit_key = page_config['limit_key']
if limit_key not in valid_input_names:
valid_keys = ', '.join(list(valid_input_names))
raise AssertionError(
"limit_key '{}' refers to a non existent "
"input member for operation: {}, valid keys: "
"{}".format(
limit_key,
operation_name,
', '.join(list(valid_input_names)),
)
f"limit_key '{limit_key}' refers to a non existent "
f"input member for operation: {operation_name}, valid keys: "
f"{valid_keys}.\n"
f"Target={operation_name}.{limit_key}"
)


Expand All @@ -237,7 +240,8 @@ def _validate_output_keys_match(operation_name, page_config, service_model):
if output_key not in output_members:
raise AssertionError(
f"Pagination key '{key_name}' refers to an output "
f"member that does not exist: {output_key}"
f"member that does not exist: {output_key}\n"
f"Target={operation_name}.{output_key}"
)
output_members.remove(output_key)

Expand All @@ -253,12 +257,10 @@ def _validate_output_keys_match(operation_name, page_config, service_model):
f.write(f"'{key}',\n")
raise AssertionError(
"There are member names in the output shape of "
"{} that are not accounted for in the pagination "
"config for service {}: {}".format(
operation_name,
service_model.service_name,
', '.join(output_members),
)
f"{operation_name} that are not accounted for in the pagination "
f"config for service {service_model.service_name}: "
f"[{', '.join(output_members)}]\n"
f"Target={operation_name}[{', '.join(output_members)}]"
)


Expand All @@ -282,7 +284,8 @@ def _validate_new_numeric_keys(operation_name, page_config, service_model):
f'{service_model.service_name} that is configured to sum '
'integer outputs across pages. Verify that this behavior is '
'correct before allow-listing, since whether or not it is '
'appropriate to sum depends on the subject matter.'
'appropriate to sum depends on the subject matter.\n'
f'Target={operation_name}'
)


Expand Down
10 changes: 8 additions & 2 deletions tests/functional/botocore/test_supported_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def _single_protocol_test_cases():
def test_services_with_protocols_trait_have_supported_protocol(
service_name, supported_protocols
):
message = f"No protocols supported for service {service_name}"
message = (
f"No protocols supported for service {service_name}\n"
f"Target={service_name}"
)
assert any(
protocol in PRIORITY_ORDERED_SUPPORTED_PROTOCOLS
for protocol in supported_protocols
Expand All @@ -68,5 +71,8 @@ def test_services_with_protocols_trait_have_supported_protocol(
def test_services_without_protocols_trait_have_supported_protocol(
service_name, supported_protocol
):
message = f"Service protocol not supported for {service_name}"
message = (
f"Service protocol not supported for {service_name}\n"
f"Target={service_name}"
)
assert supported_protocol in PRIORITY_ORDERED_SUPPORTED_PROTOCOLS, message
10 changes: 7 additions & 3 deletions tests/functional/test_no_event_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_no_event_stream_unless_allowed():
driver = create_clidriver()
help_command = driver.create_help_command()
errors = []
targets = []
for command_name, command_obj in help_command.command_table.items():
sub_help = command_obj.create_help_command()
if hasattr(sub_help, 'command_table'):
Expand All @@ -40,9 +41,12 @@ def test_no_event_stream_unless_allowed():
continue
supported_commands = '\n'.join(_ALLOWED_COMMANDS)
errors.append(
'The "%s" command uses event streams '
f'The {full_command} command uses event streams '
'which is only supported for these operations:\n'
'%s' % (full_command, supported_commands)
f'{supported_commands}\n\n'
)
targets.append(full_command)
if errors:
raise AssertionError('\n' + '\n'.join(errors))
raise AssertionError(
'\n' + '\n'.join(errors) + '\nTarget=[' + ', '.join(targets) + ']'
)
8 changes: 6 additions & 2 deletions tests/functional/test_shadowing.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def test_no_shadowed_builtins(command_name, command_table, builtins):

"""
errors = []
targets=[]
for sub_name, sub_command in command_table.items():
op_help = sub_command.create_help_command()
arg_table = op_help.arg_table
Expand All @@ -64,7 +65,10 @@ def test_no_shadowed_builtins(command_name, command_table, builtins):
# Then we are shadowing or prefixing a top level argument
errors.append(
'Shadowing/Prefixing a top level option: '
'%s.%s.%s' % (command_name, sub_name, arg_name)
f'{command_name}.{sub_name}.{arg_name}'
)
targets.append(f'{command_name}.{sub_name}.{arg_name}')
if errors:
raise AssertionError('\n' + '\n'.join(errors))
raise AssertionError(
'\n' + '\n'.join(errors) + '\nTarget=[' + ','.join(targets) + ']'
)
Loading