Esempio n. 1
0
def is_test_stories_file(file_path: Text) -> bool:
    """Checks if a file is a test stories file.

    Args:
        file_path: Path of the file which should be checked.

    Returns:
        `True` if it's a story file containing tests, otherwise `False`.
    """
    from rasa.shared.core.training_data.story_reader.yaml_story_reader import (
        YAMLStoryReader, )
    from rasa.shared.core.training_data.story_reader.markdown_story_reader import (
        MarkdownStoryReader, )

    return YAMLStoryReader.is_yaml_test_stories_file(
        file_path) or MarkdownStoryReader.is_markdown_test_stories_file(
            file_path)
Esempio n. 2
0
def test_is_not_test_story_file_if_empty(tmp_path: Path):
    path = str(tmp_path / "test_stories.yml")
    assert not YAMLStoryReader.is_yaml_test_stories_file(path)
Esempio n. 3
0
def test_is_not_test_story_file_without_test_prefix(tmp_path: Path):
    path = str(tmp_path / "stories.yml")
    rasa.shared.utils.io.write_yaml({"stories": []}, path)
    assert not YAMLStoryReader.is_yaml_test_stories_file(path)
Esempio n. 4
0
def test_is_not_test_story_file_if_it_doesnt_contain_stories(tmp_path: Path):
    path = str(tmp_path / "test_stories.yml")
    rasa.shared.utils.io.write_yaml({"nlu": []}, path)
    assert not YAMLStoryReader.is_yaml_test_stories_file(path)