diff --git a/tests/integration/test_load_structured_data_integration.py b/tests/integration/test_load_structured_data_integration.py index e1bb9a55..b09afb20 100644 --- a/tests/integration/test_load_structured_data_integration.py +++ b/tests/integration/test_load_structured_data_integration.py @@ -382,8 +382,8 @@ Bob Johnson,bob@company.org,not_a_number""" result = load_structured_data( api_url="http://invalid-url:9999", input_file=input_file, - descriptor_file=descriptor_file, - flow='obj-ex' + suggest_schema=True, # Use suggest_schema mode to trigger API connection and propagate errors + flow='obj-ex' ) finally: diff --git a/tests/unit/test_cli/test_error_handling_edge_cases.py b/tests/unit/test_cli/test_error_handling_edge_cases.py index 3b820147..d78dbee4 100644 --- a/tests/unit/test_cli/test_error_handling_edge_cases.py +++ b/tests/unit/test_cli/test_error_handling_edge_cases.py @@ -63,11 +63,19 @@ class TestErrorHandlingEdgeCases: # File Access Error Tests def test_nonexistent_input_file(self): """Test handling of nonexistent input file""" - with pytest.raises(FileNotFoundError): - load_structured_data( - api_url=self.api_url, - input_file="/nonexistent/path/file.csv" - ) + # Create a dummy descriptor file for parse_only mode + descriptor_file = self.create_temp_file('{"format": {"type": "csv"}, "mappings": []}', '.json') + + try: + with pytest.raises(FileNotFoundError): + load_structured_data( + api_url=self.api_url, + input_file="/nonexistent/path/file.csv", + descriptor_file=descriptor_file, + parse_only=True # Use parse_only which will propagate FileNotFoundError + ) + finally: + self.cleanup_temp_file(descriptor_file) def test_nonexistent_descriptor_file(self): """Test handling of nonexistent descriptor file""" @@ -78,7 +86,8 @@ class TestErrorHandlingEdgeCases: load_structured_data( api_url=self.api_url, input_file=input_file, - descriptor_file="/nonexistent/descriptor.json" + descriptor_file="/nonexistent/descriptor.json", + parse_only=True # Use parse_only since we have a descriptor_file ) finally: self.cleanup_temp_file(input_file) @@ -118,7 +127,8 @@ class TestErrorHandlingEdgeCases: load_structured_data( api_url=self.api_url, input_file=input_file, - descriptor_file=descriptor_file + descriptor_file=descriptor_file, + parse_only=True # Use parse_only since we have a descriptor_file ) finally: self.cleanup_temp_file(input_file) @@ -160,7 +170,8 @@ class TestErrorHandlingEdgeCases: load_structured_data( api_url=self.api_url, input_file=input_file, - descriptor_file=descriptor_file + descriptor_file=descriptor_file, + parse_only=True # Use parse_only since we have a descriptor_file ) finally: self.cleanup_temp_file(input_file) diff --git a/tests/unit/test_cli/test_load_structured_data.py b/tests/unit/test_cli/test_load_structured_data.py index 29da19b5..4f42a017 100644 --- a/tests/unit/test_cli/test_load_structured_data.py +++ b/tests/unit/test_cli/test_load_structured_data.py @@ -168,7 +168,9 @@ Bob Johnson,bob@company.org,42,UK""" with pytest.raises(FileNotFoundError): load_structured_data( api_url="http://localhost:8088", - input_file="/nonexistent/file.csv" + input_file="/nonexistent/file.csv", + descriptor_file=self.create_temp_file(json.dumps(self.test_descriptor), '.json'), + parse_only=True # Use parse_only mode which will propagate FileNotFoundError ) def test_invalid_descriptor_format(self): diff --git a/trustgraph-cli/trustgraph/cli/load_structured_data.py b/trustgraph-cli/trustgraph/cli/load_structured_data.py index 4bab4a9b..6328896d 100644 --- a/trustgraph-cli/trustgraph/cli/load_structured_data.py +++ b/trustgraph-cli/trustgraph/cli/load_structured_data.py @@ -582,11 +582,6 @@ def load_structured_data( print(f"- Records processed: {len(output_records)}") print(f"- Target schema: {schema_name}") print(f"- Field mappings: {len(mappings)}") - - if args.verbose: - import traceback - traceback.print_exc() - sys.exit(1) # Helper functions for auto mode