def test_trailing_match(self): conversation = Conversation() conversation.user_input = "hi my name is Rob" actual = Target.run( Mock(), conversation, RegExGrammarItem(pattern=r"\w*My name is (\w+)", dynamic_field_assignments=["user_known_as"])) self.assertTrue(actual) self.assertDictEqual({'user_known_as': 'Rob'}, conversation.current_input_context)
from dialog.schema.flow import Flow from dialog.schema.variables import Variables dialog = Dialog( flow=Flow().create(), entities=Entities().create(), variables=Variables().create() # { # "folder": [ # MainFolder.create(), # LibraryFolder.create(), # GlobalFolder.create(), # ConceptFolder.create() # ] # } # ), # Entities().create(), # Variables().create() ) user_input = dialog.entry_point(Conversation()) user_input.conversation.user_input = "My name is Rob" after_name_input = dialog.entry_point(user_input.conversation) user_input.conversation.user_input = "Yes" after_yes_shoes_input = dialog.entry_point(user_input.conversation) user_input.conversation.user_input = "high heels" after_style_input = dialog.entry_point(user_input.conversation) pass