e828acf175
CI / lint (push) Successful in 1m32s
CI / typecheck (push) Successful in 1m38s
CI / lint (pull_request) Successful in 1m30s
CI / typecheck (pull_request) Successful in 1m30s
CI / behave (3.11) (pull_request) Successful in 1m39s
CI / behave (3.12) (pull_request) Successful in 1m39s
CI / build (pull_request) Successful in 1m29s
CI / behave (3.13) (pull_request) Successful in 1m39s
CI / behave (3.11) (push) Successful in 1m39s
CI / behave (3.12) (push) Successful in 1m41s
CI / behave (3.13) (push) Successful in 1m37s
CI / build (push) Successful in 1m30s
ISSUES CLOSED: #1
121 lines
7.1 KiB
Plaintext
121 lines
7.1 KiB
Plaintext
*** Settings ***
|
|
Documentation Test suite for error handling and exception scenarios
|
|
Library ${CURDIR}/libraries/CleverRDFLibKeywords.py
|
|
Library Collections
|
|
Library OperatingSystem
|
|
Library String
|
|
|
|
*** Test Cases ***
|
|
Load Non-Existent File Should Raise Exception
|
|
[Documentation] Test that loading a non-existent file results in errors with specific error details
|
|
[Tags] error_handling exceptions
|
|
Create Ontology Loader
|
|
Load Ontology non_existent_file.ttl
|
|
Result Should Have Errors
|
|
${result}= Get Result
|
|
${error_count}= Evaluate len($result.errors) modules=builtins
|
|
Should Be True ${error_count} > 0 Expected at least one error for non-existent file
|
|
# Verify error contains file-related information
|
|
${errors}= Evaluate $result.errors modules=builtins
|
|
${first_error}= Get From List ${errors} 0
|
|
${error_message}= Evaluate $first_error.get('message', str($first_error)) if isinstance($first_error, dict) else str($first_error) modules=builtins
|
|
Should Contain ${error_message} non_existent_file.ttl Error message should mention the file that failed to load
|
|
|
|
Load Invalid Path Should Fail
|
|
[Documentation] Test that loading from an invalid path fails appropriately with specific error details
|
|
[Tags] error_handling exceptions
|
|
Create Ontology Loader
|
|
Load Ontology /invalid/path/that/does/not/exist.ttl
|
|
Result Should Have Errors
|
|
${result}= Get Result
|
|
${errors}= Evaluate $result.errors modules=builtins
|
|
Should Not Be Empty ${errors}
|
|
# Verify error contains path-related information
|
|
${first_error}= Get From List ${errors} 0
|
|
${error_message}= Evaluate $first_error.get('message', str($first_error)) if isinstance($first_error, dict) else str($first_error) modules=builtins
|
|
${contains_path}= Evaluate '/invalid/path' in $error_message or 'exist' in $error_message.lower() modules=builtins
|
|
Should Be True ${contains_path} Error message should mention the invalid path or contain 'exist': ${error_message}
|
|
|
|
Load Empty File Should Handle Gracefully
|
|
[Documentation] Test that loading an empty file is handled gracefully without crashing
|
|
[Tags] error_handling exceptions
|
|
${empty_file}= Set Variable ${CURDIR}${/}test_data${/}empty.ttl
|
|
Create File ${empty_file} ${EMPTY}
|
|
Create Ontology Loader
|
|
${status} ${result}= Run Keyword And Ignore Error Load Ontology ${empty_file}
|
|
# Verify that loading succeeded (empty graph)
|
|
Should Be Equal ${status} PASS
|
|
${result_obj}= Get Result
|
|
Should Not Be Equal ${result_obj} ${None}
|
|
${graph}= Get Merged Graph
|
|
Should Not Be Equal ${graph} ${None}
|
|
[Teardown] Remove File ${empty_file}
|
|
|
|
Load Ontology With Invalid Syntax Should Handle Gracefully
|
|
[Documentation] Test that loading an ontology with invalid syntax is handled gracefully with error information
|
|
[Tags] error_handling exceptions
|
|
${invalid_file}= Set Variable ${CURDIR}${/}test_data${/}invalid_syntax.ttl
|
|
Create File ${invalid_file} This is not valid Turtle syntax!!!
|
|
Create Ontology Loader
|
|
Load Ontology ${invalid_file}
|
|
# Invalid syntax should result in errors in the result
|
|
${result}= Get Result
|
|
Should Not Be Equal ${result} ${None}
|
|
${errors}= Evaluate $result.errors modules=builtins
|
|
# Invalid syntax should produce errors
|
|
Should Not Be Equal ${errors} ${None}
|
|
Should Be True isinstance($errors, list) Errors should be a list
|
|
${error_count}= Get Length ${errors}
|
|
Should Be True ${error_count} > 0 Errors list should contain at least one error for invalid syntax
|
|
# Verify error message contains relevant information
|
|
${first_error}= Get From List ${errors} 0
|
|
${error_message}= Evaluate $first_error.get('message', str($first_error)) if isinstance($first_error, dict) else str($first_error) modules=builtins
|
|
Should Not Be Empty ${error_message} Error message should not be empty
|
|
[Teardown] Remove File ${invalid_file}
|
|
|
|
Access Result Before Loading Should Fail
|
|
[Documentation] Test that accessing result before loading raises appropriate error with specific message
|
|
[Tags] error_handling exceptions
|
|
Create Ontology Loader
|
|
${error}= Run Keyword And Expect Error * Get Merged Graph
|
|
Should Contain ${error} No loading result available
|
|
${contains_instruction}= Evaluate 'Load an ontology first' in $error or 'load' in $error.lower() modules=builtins
|
|
Should Be True ${contains_instruction} Error should indicate that loading is required: ${error}
|
|
|
|
Access Class Hierarchy Before Loading Should Fail
|
|
[Documentation] Test that accessing class hierarchy before loading raises error with specific message
|
|
[Tags] error_handling exceptions
|
|
Create Ontology Loader
|
|
${error}= Run Keyword And Expect Error * Get Class Hierarchy
|
|
Should Contain ${error} No loading result available
|
|
${contains_instruction}= Evaluate 'Load an ontology first' in $error or 'load' in $error.lower() modules=builtins
|
|
Should Be True ${contains_instruction} Error should indicate that loading is required: ${error}
|
|
|
|
Access OWL Metadata Before Loading Should Fail
|
|
[Documentation] Test that accessing OWL metadata before loading raises error with specific message
|
|
[Tags] error_handling exceptions
|
|
Create Ontology Loader
|
|
${error}= Run Keyword And Expect Error * Get OWL Metadata
|
|
Should Contain ${error} No loading result available
|
|
${contains_instruction}= Evaluate 'Load an ontology first' in $error or 'load' in $error.lower() modules=builtins
|
|
Should Be True ${contains_instruction} Error should indicate that loading is required: ${error}
|
|
|
|
Invalid Strategy Should Raise Error
|
|
[Documentation] Test that providing an invalid strategy raises an error with specific message
|
|
[Tags] error_handling exceptions
|
|
${error}= Run Keyword And Expect Error * Create Ontology Loader strategy=invalid_strategy
|
|
Should Not Be Empty ${error}
|
|
${contains_keyword}= Evaluate 'invalid' in $error.lower() or 'strategy' in $error.lower() or 'unknown' in $error.lower() modules=builtins
|
|
Should Be True ${contains_keyword} Error should mention invalid strategy: ${error}
|
|
|
|
Negative Max Depth Should Be Handled
|
|
[Documentation] Test that negative max depth is handled appropriately without crashing
|
|
[Tags] error_handling exceptions
|
|
${status} ${result}= Run Keyword And Ignore Error Create Ontology Loader max_depth=-1
|
|
# Should either succeed (if negative depth is allowed) or fail gracefully
|
|
Should be Equal ${status} FAIL
|
|
${result_lower}= Convert To Lowercase ${result}
|
|
${contains_keyword}= Evaluate 'max-depth' in $result_lower and 'greater than 0' in $result_lower modules=builtins
|
|
Should Be True ${contains_keyword} Error should mention max_depth if validation occurs: ${result}
|
|
|