diff --git a/src/datacustomcode/cli.py b/src/datacustomcode/cli.py index e2690a6f..a22fcb5b 100644 --- a/src/datacustomcode/cli.py +++ b/src/datacustomcode/cli.py @@ -351,14 +351,27 @@ def init(directory: str, code_type: str, use_in_feature: Optional[str]): + " to automatically update config.json when you make changes to your code" ) - # Generate test.json for functions + # Prefer the sample tests/test.json shipped in the template; only + # generate one from the request model if the template doesn't have it if code_type == "function": - test_json_path = _generate_function_test_file(entrypoint_path) - if test_json_path: + template_test_json = os.path.join( + os.path.dirname(entrypoint_path), TESTS_DIR, TEST_FILE + ) + test_json_path: Optional[str] + if os.path.isfile(template_test_json): + test_json_path = template_test_json click.echo( - "Generated test file at " + "Sample test file at " + click.style(test_json_path, fg="blue", bold=True) ) + else: + test_json_path = _generate_function_test_file(entrypoint_path) + if test_json_path: + click.echo( + "Generated test file at " + + click.style(test_json_path, fg="blue", bold=True) + ) + if test_json_path: click.echo( "Test your function locally with " + click.style( diff --git a/src/datacustomcode/templates/function/chunking/payload/tests/test.json b/src/datacustomcode/templates/function/chunking/payload/tests/test.json new file mode 100644 index 00000000..63623b9b --- /dev/null +++ b/src/datacustomcode/templates/function/chunking/payload/tests/test.json @@ -0,0 +1,33 @@ +{ + "input": [ + { + "text": "Online Remittance Instructions", + "metadata": { + "type": "text", + "page_number": 1, + "transcript_fields": { + "speaker": "Agent", + "start_timestamp": 1.0, + "end_timestamp": 8.75 + }, + "text_as_html": "

Online Remittance Instructions

", + "source_dmo_fields": { + "FilePath__c": "quarterly_report.pdf", + "Size__c": 1377454.0, + "ContentType__c": "pdf", + "LastModified__c": "2026-03-25T02:01:24.918000" + }, + "prepend": [ + { + "dmo_name": "udmo_1__dlm", + "field_name": "ResolvedFilePath__c", + "value": "udlo_1__dll:quarterly_report.pdf" + } + ], + "image_base64": "sample_image_base64", + "image_mime_type": "image/png", + "image_type": "diagram" + } + } + ] +} \ No newline at end of file