From 44f81c3e0d79547979536c686e962274b6d39f26 Mon Sep 17 00:00:00 2001 From: Rita Agarwala Date: Thu, 12 Nov 2026 14:23:46 +0530 Subject: [PATCH 1/2] Copying tests/test.json from templates instead of generating a new one --- src/datacustomcode/cli.py | 19 ++++++++--- .../function/chunking/payload/tests/test.json | 33 +++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 src/datacustomcode/templates/function/chunking/payload/tests/test.json diff --git a/src/datacustomcode/cli.py b/src/datacustomcode/cli.py index e2690a6f..801fe7c3 100644 --- a/src/datacustomcode/cli.py +++ b/src/datacustomcode/cli.py @@ -351,14 +351,25 @@ 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: + test_json_path: Optional[str] = os.path.join( + os.path.dirname(entrypoint_path), TESTS_DIR, TEST_FILE + ) + if os.path.isfile(test_json_path): 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 From 63a5349388cf1d4886348857dc00a7494dd7dacc Mon Sep 17 00:00:00 2001 From: Rita Agarwala Date: Thu, 12 Nov 2026 14:31:53 +0530 Subject: [PATCH 2/2] Lint error fix --- src/datacustomcode/cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/datacustomcode/cli.py b/src/datacustomcode/cli.py index 801fe7c3..a22fcb5b 100644 --- a/src/datacustomcode/cli.py +++ b/src/datacustomcode/cli.py @@ -354,10 +354,12 @@ def init(directory: str, code_type: str, use_in_feature: Optional[str]): # 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: Optional[str] = os.path.join( + template_test_json = os.path.join( os.path.dirname(entrypoint_path), TESTS_DIR, TEST_FILE ) - if os.path.isfile(test_json_path): + test_json_path: Optional[str] + if os.path.isfile(template_test_json): + test_json_path = template_test_json click.echo( "Sample test file at " + click.style(test_json_path, fg="blue", bold=True)