From 28776e5ffeaf2b357bf9857abce2c93e12ea3365 Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Wed, 14 Aug 2024 12:02:18 +0200 Subject: [PATCH] Add another test --- tests/test_dsl_yaml.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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'