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
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
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)
def dialog_submission(request): return Action.from_http(raw_action(request))
def interactive_message(request): return Action.from_http(raw_action(request))
def action(request): return Action.from_http(raw_action(request))
def test_from_http(self, action): act = Action.from_http(action) assert isinstance(act, slack.actions.Action)
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"
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"])
def test_mapping_access(self, action): act = Action.from_http(action) assert act["callback_id"] == "test_action"
def message_action(request): return Action.from_http(raw_action(request))