From 225089eeb4b37965ea9aa0faacdcba29d93d5532 Mon Sep 17 00:00:00 2001 From: Matt Storey Date: Tue, 1 Oct 2024 14:53:42 +0100 Subject: [PATCH] CTOOLS-373: Testing key --- generate/templates/api_test.mustache | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/generate/templates/api_test.mustache b/generate/templates/api_test.mustache index 5248370..f945e1a 100644 --- a/generate/templates/api_test.mustache +++ b/generate/templates/api_test.mustache @@ -99,6 +99,16 @@ class {{#operations}}Test{{classname}}(unittest.IsolatedAsyncioTestCase): # {{complexType}} if "example" in jsonContent: {{paramName}}: {{dataType}} = jsonContent["example"] + + if isinstance(jsonContent, object): + is_key = list(jsonContent.keys())[0] if len(jsonContent.keys()) > 0 else None + + if is_key is not None: + if list(jsonContent.keys())[0] == 'data-access-page-evaluation': + request_body: Dict[str, EvaluationRequest] = jsonContent["example"]["data-access-page-evaluation"] + else: + request_body: Dict[str, EvaluationRequest] = jsonContent["example"] + elif "examples" in jsonContent: examples = jsonContent["examples"] examples = [examples[key] for key in examples]