-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for flows io, fixed bug that made serialization and deser…
…ialization unequal
- Loading branch information
1 parent
8c0260b
commit 48c0718
Showing
10 changed files
with
85 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
flows: | ||
foo: | ||
description: "A test flow" | ||
steps: | ||
- action: "utter_test" | ||
bar: | ||
description: "Another test flow" | ||
steps: | ||
- action: "utter_greet" | ||
- collect: "important_info" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import pytest | ||
import tempfile | ||
from rasa.shared.core.flows.yaml_flows_io import ( | ||
is_flows_file, | ||
YAMLFlowsReader, | ||
YamlFlowsWriter, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def basic_flows_file(tests_data_folder: str) -> str: | ||
return os.path.join(tests_data_folder, "test_flows", "basic_flows.yml") | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"path, expected_result", | ||
[ | ||
(os.path.join("test_flows", "basic_flows.yml"), True), | ||
(os.path.join("test_moodbot", "domain.yml"), False), | ||
], | ||
) | ||
def test_is_flows_file(tests_data_folder: str, path: str, expected_result: bool): | ||
full_path = os.path.join(tests_data_folder, path) | ||
assert is_flows_file(full_path) == expected_result | ||
|
||
|
||
def test_flow_reading(basic_flows_file: str): | ||
flows_list = YAMLFlowsReader.read_from_file(basic_flows_file) | ||
assert len(flows_list) == 2 | ||
assert flows_list.flow_by_id("foo") is not None | ||
assert flows_list.flow_by_id("bar") is not None | ||
|
||
|
||
def test_flow_writing(basic_flows_file: str): | ||
flows_list = YAMLFlowsReader.read_from_file(basic_flows_file) | ||
tmp_file_descriptor, tmp_file_name = tempfile.mkstemp() | ||
YamlFlowsWriter.dump(flows_list.underlying_flows, tmp_file_name) | ||
|
||
re_read_flows_list = YAMLFlowsReader.read_from_file(tmp_file_name) | ||
assert re_read_flows_list == flows_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters