Пример #1
0
    def test_no_slot_child_3(self):

        user = AppUser.setup("testid")
        child = user.add_child("Jane","555")
        user.add_child("Jill","444")

        event = self._build_test_event(
            intent="AddBeReadyBy",
            slots=self.slots,
            transcript="record_id|-1",
        )

        resp = route_logic(event)

        #incorrect child id
        self._test_intent_case(resp,"no_slot_child")

        #correct child id
        event = self._build_test_event(
            intent="AddBeReadyBy",
            slots=self.slots,
            transcript="record_id|%s" % child.id,
            session = {
                "last_case": "no_slot_child",
                "current_slot": "child",
                "attempt_count": 1
            }
        )

        resp = route_logic(event)

        #correct, move on
        self._test_intent_case(resp,"no_slot_time")
Пример #2
0
    def test_no_child(self):

        user = AppUser.setup("testid")

        event = self.build_test_event("ParentOrbChild", "CatchAll", self.slots,
                                      "hello")

        resp = route_logic(event)

        self.check_intent_case(resp, "no_child")
Пример #3
0
    def test_missing_child(self):

        event = self._build_test_event(
            "AddBeReadyBy",
            self.slots,
            "add be ready by"
        )

        resp = route_logic(event)

        self._test_intent_case(resp,"missing_child")
Пример #4
0
    def test_no_slot_child_1(self):

        user = AppUser.setup("testid")
        user.add_child("Jane","555")

        event = self._build_test_event(
            intent="AddBeReadyBy",
            slots=self.slots,
        )

        resp = route_logic(event)

        #child can be derived so it will move on
        self._test_intent_case(resp,"no_slot_time")
Пример #5
0
    def test_no_slot_child_2(self):

        user = AppUser.setup("testid")
        user.add_child("Jane","555")
        user.add_child("Jill","444")

        event = self._build_test_event(
            intent="AddBeReadyBy",
            slots=self.slots,
        )

        resp = route_logic(event)

        #child can't be derived so ask
        self._test_intent_case(resp,"no_slot_child")
Пример #6
0
    def test_missing_timezone(self):

        user = AppUser.setup("testid")
        user.add_child("Jane","555")
        user.time_offset = None
        user.save()

        event = self._build_test_event(
            "AddBeReadyBy",
            self.slots,
            "add be ready by"
        )

        resp = route_logic(event)

        self._test_intent_case(resp,"missing_timezone")
Пример #7
0
    def test_no_slot_time(self):
        user = AppUser.setup("testid")
        child = user.add_child("Jane","555")

        self.slots['child'] = child.first_name
        self.slots['time'] = "zzzz"

        event = self._build_test_event(
            intent="AddBeReadyBy",
            slots=self.slots,
            session = {
                "last_case": "no_slot_time",
                "current_slot": "time",
                "attempt_count": 1
            }
        )

        resp = route_logic(event)
Пример #8
0
    def test_no_action_default(self):

        user = AppUser.setup("testid")
        child = user.add_child("Jane", "+555")

        user.add_reminder(child_id=child.id,
                          kind=100,
                          for_desc='brand practice',
                          is_repeated=False,
                          choosen_date="2017-08-01",
                          reminder_time="16:30",
                          days_selected=None)

        user.schedule_actions()

        event = self.build_test_event("ParentOrbChild",
                                      "CatchAll",
                                      self.slots,
                                      "hello",
                                      userId="555")

        resp = route_logic(event)
Пример #9
0
def handler(event, context):

    #for manual commands, taken from zappa
    if event.get('detail-type') == u'Scheduled Event':
        whole_function = event['resources'][0].split('/')[-1].split('-')[-1]

        # This is a scheduled function.
        if '.' in whole_function:
            app_function = import_module_and_get_function(whole_function)

            return run_function(app_function, event, context)
    elif event.get('command', None):
        whole_function = event['command']
        extra_args = whole_function.split(' ')[1:]
        whole_function = whole_function.split(' ')[0]
        app_function = import_module_and_get_function(whole_function)
        result = run_function(app_function, event, context, extra_args)
        print("Result of %s:" % whole_function)
        print(result)
        return result

    #default is route to bot
    return route_logic(event)
Пример #10
0
    def test_intro(self, get_profile):

        event = self._load_event("AddReminder")

        route_logic(event)