Skip to content

Commit d89393a

Browse files
Add model validation test for completions-1.json operation references (aws#10118)
1 parent 7611079 commit d89393a

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/functional/autocomplete/test_completion_files.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,35 @@ def get_models_with_completions():
107107
return models
108108

109109

110+
def _get_invalid_completion_operations():
111+
cases = []
112+
for test_data in get_models_with_completions():
113+
known_ops = set(test_data.service_model['operations'])
114+
for op_name in test_data.completions['operations']:
115+
if op_name not in known_ops:
116+
cases.append((test_data.service_name, op_name))
117+
return cases
118+
119+
120+
@pytest.mark.validates_models
121+
@pytest.mark.parametrize(
122+
"service_name, operation_name",
123+
_get_invalid_completion_operations(),
124+
ids=lambda val: str(val),
125+
)
126+
def test_completions_operations_exist_in_model(
127+
service_name, operation_name, record_property
128+
):
129+
record_property('aws_service', service_name)
130+
record_property('aws_operation', operation_name)
131+
pytest.fail(
132+
f"Completions file for '{service_name}' references operation "
133+
f"'{operation_name}' which does not exist in the service model. "
134+
f"The completions-1.json file must be updated to remove or "
135+
f"update references to this operation."
136+
)
137+
138+
110139
@pytest.mark.parametrize(
111140
"test_data",
112141
get_models_with_completions(),

0 commit comments

Comments
 (0)