Example #1
0
def test_reminder_scheduled(default_processor):
    out = CollectingOutputChannel()
    sender_id = uuid.uuid4().hex

    d = Dispatcher(sender_id, out, default_processor.nlg)
    r = ReminderScheduled("utter_greet", datetime.datetime.now())
    t = default_processor.tracker_store.get_or_create_tracker(sender_id)

    t.update(UserUttered("test"))
    t.update(ActionExecuted("action_reminder_reminder"))
    t.update(r)

    default_processor.tracker_store.save(t)
    default_processor.handle_reminder(r, d)

    # retrieve the updated tracker
    t = default_processor.tracker_store.retrieve(sender_id)
    assert t.events[-4] == UserUttered(None)
    assert t.events[-3] == ActionExecuted("utter_greet")
    assert t.events[-2] == BotUttered("hey there None!", {
        'elements': None,
        'buttons': None,
        'attachment': None
    })
    assert t.events[-1] == ActionExecuted("action_listen")
Example #2
0
    def run(self, dispatcher, tracker, domain):
        bot_reply_message = "Guten Tag, mein Name ist Carina. " \
                            "Ich kann Informationen abrufen " \
                            "oder einfach eine Unterhaltung führen. " \
                            "Was möchten Sie tun?"
        buttons = [{"title": 'Informationen abrufen', "payload": "/getinformation"},
                   {"title": 'Unterhaltung beginnen', "payload": "/chatting"}]
        dispatcher.utter_button_message(text=bot_reply_message, buttons=buttons)

        trigger_date = None
        if trigger_date:
            return [ReminderScheduled('action_remind_drink', trigger_date, kill_on_user_message=True)]

        return []
Example #3
0
def test_json_parse_reminder():
    # DOCS MARKER ReminderScheduled
    evt = \
        {
            'event': 'reminder',
            'action': 'my_action',
            'date_time': '2018-09-03T11:41:10.128172',
            'name': 'my_reminder',
            'kill_on_user_msg': True
        }
    # DOCS END
    assert Event.from_parameters(evt) == ReminderScheduled(
        "my_action",
        parser.parse('2018-09-03T11:41:10.128172'),
        name='my_reminder',
        kill_on_user_message=True)
Example #4
0
def test_reminder_aborted(default_processor):
    out = CollectingOutputChannel()
    sender_id = uuid.uuid4().hex

    d = Dispatcher(sender_id, out, default_processor.nlg)
    r = ReminderScheduled("utter_greet", datetime.datetime.now(),
                          kill_on_user_message=True)
    t = default_processor.tracker_store.get_or_create_tracker(sender_id)

    t.update(r)
    t.update(UserUttered("test"))  # cancels the reminder

    default_processor.tracker_store.save(t)
    default_processor.handle_reminder(r, d)

    # retrieve the updated tracker
    t = default_processor.tracker_store.retrieve(sender_id)
    assert len(t.events) == 3  # nothing should have been executed
Example #5
0
    }, []), UserUttered("/goodbye", {
        "name": "goodbye",
        "confidence": 1.0
    }, [])),
    (TopicSet("my_topic"), TopicSet("my_other_topic")),
    (SlotSet("my_slot", "value"), SlotSet("my__other_slot", "value")),
    (Restarted(), None),
    (AllSlotsReset(), None),
    (ConversationPaused(), None),
    (ConversationResumed(), None),
    (StoryExported(), None),
    (ActionReverted(), None),
    (ActionExecuted("my_action"), ActionExecuted("my_other_action")),
    (BotUttered("my_text",
                "my_data"), BotUttered("my_other_test", "my_other_data")),
    (ReminderScheduled("my_action",
                       "now"), ReminderScheduled("my_other_action", "now")),
])
def test_event_has_proper_implementation(one_event, another_event):
    # equals tests
    assert one_event != another_event, \
        "Same events with different values need to be different"
    assert one_event == deepcopy(one_event), \
        "Event copies need to be the same"
    assert one_event != 42, \
        "Events aren't equal to 42!"

    # hash test
    assert hash(one_event) == hash(deepcopy(one_event)), \
        "Same events should have the same hash"
    assert hash(one_event) != hash(another_event), \
        "Different events should have different hashes"
Example #6
0
    }, [])),
    (SlotSet("my_slot", "value"), SlotSet("my__other_slot", "value")),
    (Restarted(), None),
    (AllSlotsReset(), None),
    (ConversationPaused(), None),
    (ConversationResumed(), None),
    (StoryExported(), None),
    (ActionReverted(), None),
    (UserUtteranceReverted(), None),
    (ActionExecuted("my_action"), ActionExecuted("my_other_action")),
    (FollowupAction("my_action"), FollowupAction("my_other_action")),
    (BotUttered("my_text",
                "my_data"), BotUttered("my_other_test", "my_other_data")),
    (AgentUttered("my_text",
                  "my_data"), AgentUttered("my_other_test", "my_other_data")),
    (ReminderScheduled("my_action", datetime.now()),
     ReminderScheduled("my_other_action", datetime.now())),
])
def test_event_has_proper_implementation(one_event, another_event):
    # equals tests
    assert one_event != another_event, \
        "Same events with different values need to be different"
    assert one_event == copy.deepcopy(one_event), \
        "Event copies need to be the same"
    assert one_event != 42, \
        "Events aren't equal to 42!"

    # hash test
    assert hash(one_event) == hash(copy.deepcopy(one_event)), \
        "Same events should have the same hash"
    assert hash(one_event) != hash(another_event), \
Example #7
0
    (TopicSet("my_topic"),
     TopicSet("my_other_topic")),

    (SlotSet("my_slot", "value"),
     SlotSet("my__other_slot", "value")),

    (Restarted(),
     None),

    (AllSlotsReset(),
     None),

    (ActionExecuted("my_action"),
     ActionExecuted("my_other_action")),

    (ReminderScheduled("my_action", "now"),
     ReminderScheduled("my_other_action", "now")),
])
def test_event_has_proper_implementation(one_event, another_event):
    # equals tests
    assert one_event != another_event, \
        "Same events with different values need to be different"
    assert one_event == deepcopy(one_event), \
        "Event copies need to be the same"
    assert one_event != 42, \
        "Events aren't equal to 42!"

    # hash test
    assert hash(one_event) == hash(deepcopy(one_event)), \
        "Same events should have the same hash"
    assert hash(one_event) != hash(another_event), \