Beispiel #1
0
    def test_no_dispatch(self, action, action_router):
        def handler():
            pass

        act = Action.from_http(action)
        action_router.register("xxx", handler)

        for h in action_router.dispatch(act):
            assert False
Beispiel #2
0
    def test_dispath(self, action, action_router):
        def handler():
            pass

        act = Action.from_http(action)
        action_router.register("test_action", handler)

        handlers = list()
        for h in action_router.dispatch(act):
            handlers.append(h)
        assert len(handlers) == 1
        assert handlers[0] is handler
Beispiel #3
0
async def incoming_action(request):
    slack = request.app.plugins['slack']
    payload = await request.post()
    LOG.log(5, 'Incoming action payload: %s', payload)

    try:
        action = Action.from_http(payload, verification_token=slack.verify)
    except FailedVerification:
        return Response(status=401)

    LOG.debug('Incoming action: %s', action)

    futures = list(_dispatch(slack.routers['action'], action, request.app))
    if futures:
        return await _wait_and_check_result(futures)

    return Response(status=200)
async def incoming_action(request):
    slack = request.app.plugins["slack"]
    payload = await request.post()
    LOG.log(5, "Incoming action payload: %s", payload)

    try:
        verification_token = await _validate_request(request, slack)
        action = Action.from_http(payload,
                                  verification_token=verification_token)
    except (FailedVerification, InvalidSlackSignature, InvalidTimestamp):
        return Response(status=401)

    LOG.debug("Incoming action: %s", action)

    futures = list(_dispatch(slack.routers["action"], action, request.app))
    if futures:
        return await _wait_and_check_result(futures)

    return Response(status=200)
Beispiel #5
0
def dialog_submission(request):
    return Action.from_http(raw_action(request))
Beispiel #6
0
def interactive_message(request):
    return Action.from_http(raw_action(request))
Beispiel #7
0
def action(request):
    return Action.from_http(raw_action(request))
Beispiel #8
0
 def test_from_http(self, action):
     act = Action.from_http(action)
     assert isinstance(act, slack.actions.Action)
Beispiel #9
0
 def test_mapping_set(self, action):
     act = Action.from_http(action)
     assert act["callback_id"] == "test_action"
     act["callback_id"] = "foo"
     assert act["callback_id"] == "foo"
Beispiel #10
0
 def test_mapping_delete(self, action):
     act = Action.from_http(action)
     assert act["callback_id"] == "test_action"
     del act["callback_id"]
     with pytest.raises(KeyError):
         print(act["callback_id"])
Beispiel #11
0
 def test_mapping_access(self, action):
     act = Action.from_http(action)
     assert act["callback_id"] == "test_action"
Beispiel #12
0
def message_action(request):
    return Action.from_http(raw_action(request))