diff --git a/tests/test_dsl_yaml.py b/tests/test_dsl_yaml.py index 497f1da4..0f45d701 100644 --- a/tests/test_dsl_yaml.py +++ b/tests/test_dsl_yaml.py @@ -31,6 +31,7 @@ ) from tested.testsuite import ( CustomCheckOracle, + FileOutputChannel, FileUrl, GenericTextOracle, GenericValueOracle, @@ -657,6 +658,37 @@ def test_value_built_in_checks_implied(): ) +def test_file_custom_check_correct(): + yaml_str = f""" + - tab: 'Test' + contexts: + - testcases: + - statement: 'test()' + file: + content: "test/hallo.txt" + oracle: "custom_check" + location: "test.txt" + name: "evaluate_test" + file: "test.py" + """ + json_str = translate_to_test_suite(yaml_str) + suite = parse_test_suite(json_str) + assert len(suite.tabs) == 1 + tab = suite.tabs[0] + assert len(tab.contexts) == 1 + testcases = tab.contexts[0].testcases + assert len(testcases) == 1 + test = testcases[0] + assert isinstance(test.input, FunctionCall) + assert isinstance(test.output.file, FileOutputChannel) + assert isinstance(test.output.file.oracle, CustomCheckOracle) + assert test.output.file.actual_path == "test.txt" + assert test.output.file.expected_path == "test/hallo.txt" + oracle = test.output.file.oracle + assert oracle.function.name == "evaluate_test" + assert oracle.function.file == Path("test.py") + + def test_value_built_in_checks_explicit(): yaml_str = f""" - tab: 'Test'