Пример #1
0
    async def _add_e2e_messages(self, e2e_messages: List[Text],
                                line_num: int) -> None:
        if not self.current_step_builder:
            raise StoryParseError("End-to-end message '{}' at invalid "
                                  "location. Expected story start."
                                  "".format(e2e_messages))
        e2e_reader = EndToEndReader()
        parsed_messages = []
        for m in e2e_messages:
            message = e2e_reader._parse_item(m)
            parsed = await self._parse_message(message.text, line_num)

            parsed.parse_data["true_intent"] = message.data["true_intent"]
            parsed.parse_data["true_entities"] = message.data.get(
                "entities") or []
            parsed_messages.append(parsed)
        self.current_step_builder.add_user_messages(parsed_messages)
Пример #2
0
def test_invalid_end_to_end_format(line: Text):
    reader = EndToEndReader()

    with pytest.raises(ValueError):
        # noinspection PyProtectedMember
        _ = reader._parse_item(line)
Пример #3
0
def test_e2e_parsing(line: Text, expected: Dict):
    reader = EndToEndReader()
    actual = reader._parse_item(line)

    assert actual.as_dict() == expected
Пример #4
0
def test_invalid_end_to_end_format(line: Text):
    reader = EndToEndReader()

    with pytest.raises(ValueError):
        _ = reader._parse_item(line)