Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
leverage functions_completeSuccess
Browse files Browse the repository at this point in the history
WilliamBergamin committed Nov 24, 2023
1 parent 3fc4db8 commit 6101d51
Showing 7 changed files with 25 additions and 54 deletions.
9 changes: 3 additions & 6 deletions slack_bolt/app/app.py
Original file line number Diff line number Diff line change
@@ -849,12 +849,9 @@ def function(
def reverse_string(event, client: WebClient, context: BoltContext):
try:
string_to_reverse = event["inputs"]["stringToReverse"]
client.api_call(
"functions.completeSuccess",
json={
"function_execution_id": context.function_execution_id,
"outputs": {"reverseString": string_to_reverse[::-1]},
},
client.functions_completeSuccess(
function_execution_id=context.function_execution_id,
outputs={"reverseString": string_to_reverse[::-1]},
)
except Exception as e:
client.api_call(
9 changes: 3 additions & 6 deletions slack_bolt/app/async_app.py
Original file line number Diff line number Diff line change
@@ -882,12 +882,9 @@ def function(
async def reverse_string(event, client: AsyncWebClient, complete: AsyncComplete):
try:
string_to_reverse = event["inputs"]["stringToReverse"]
await client.api_call(
"functions.completeSuccess",
json={
"function_execution_id": context.function_execution_id,
"outputs": {"reverseString": string_to_reverse[::-1]},
},
await client.functions_completeSuccess(
function_execution_id=context.function_execution_id,
outputs={"reverseString": string_to_reverse[::-1]},
)
except Exception as e:
await client.functions_completeError(
9 changes: 3 additions & 6 deletions slack_bolt/logger/messages.py
Original file line number Diff line number Diff line change
@@ -280,12 +280,9 @@ def warning_unhandled_request( # type: ignore
try:
# TODO: do something here
outputs = {{}}
{'await ' if is_async else ''}client.api_call(
"functions.completeSuccess",
json={{
"function_execution_id": context.function_execution_id,
"outputs": outputs,
}},
{'await ' if is_async else ''}client.functions_completeSuccess(
function_execution_id=context.function_execution_id,
outputs=outputs,
)
except Exception as e:
error = f"Failed to handle a function request (error: {{e}})"
16 changes: 4 additions & 12 deletions tests/scenario_tests/test_function.py
Original file line number Diff line number Diff line change
@@ -210,12 +210,9 @@ def reverse(body, event, context, client):
assert context.function_bot_access_token == "xwfp-valid"
assert context.client.token == "xwfp-valid"
assert client.token == "xwfp-valid"
client.api_call(
"functions.completeSuccess",
json={
"function_execution_id": event["function_execution_id"],
"outputs": {"reverseString": "olleh"},
},
client.functions_completeSuccess(
function_execution_id=event["function_execution_id"],
outputs={"reverseString": "olleh"},
)


@@ -228,9 +225,4 @@ def reverse_error(body, event, client, context):
def complete_it(body, event, client):
assert body == function_body
assert event == function_body["event"]
client.api_call(
"functions.completeSuccess",
json={
"function_execution_id": event["function_execution_id"],
},
)
client.functions_completeSuccess(function_execution_id=event["function_execution_id"], outputs={})
18 changes: 6 additions & 12 deletions tests/scenario_tests_async/test_function.py
Original file line number Diff line number Diff line change
@@ -214,12 +214,9 @@ async def reverse(body, event, client, context):
assert context.function_bot_access_token == "xwfp-valid"
assert context.client.token == "xwfp-valid"
assert client.token == "xwfp-valid"
await client.api_call(
"functions.completeSuccess",
json={
"function_execution_id": event["function_execution_id"],
"outputs": {"reverseString": "olleh"},
},
await client.functions_completeSuccess(
function_execution_id=event["function_execution_id"],
outputs={"reverseString": "olleh"},
)


@@ -235,10 +232,7 @@ async def reverse_error(body, event, client, context):
async def complete_it(body, event, client):
assert body == function_body
assert event == function_body["event"]
await client.api_call(
"functions.completeSuccess",
json={
"function_execution_id": event["function_execution_id"],
"outputs": {},
},
await client.functions_completeSuccess(
function_execution_id=event["function_execution_id"],
outputs={},
)
9 changes: 3 additions & 6 deletions tests/slack_bolt/logger/test_unmatched_suggestions.py
Original file line number Diff line number Diff line change
@@ -98,12 +98,9 @@ def handle_some_function(body, event, client, logger):
try:
# TODO: do something here
outputs = {{}}
client.api_call(
"functions.completeSuccess",
json={{
"function_execution_id": context.function_execution_id,
"outputs": outputs,
}},
client.functions_completeSuccess(
function_execution_id=context.function_execution_id,
outputs=outputs,
)
except Exception as e:
error = f"Failed to handle a function request (error: {{e}})"
9 changes: 3 additions & 6 deletions tests/slack_bolt_async/logger/test_unmatched_suggestions.py
Original file line number Diff line number Diff line change
@@ -98,12 +98,9 @@ async def handle_some_function(body, event, client, logger):
try:
# TODO: do something here
outputs = {{}}
await client.api_call(
"functions.completeSuccess",
json={{
"function_execution_id": context.function_execution_id,
"outputs": outputs,
}},
await client.functions_completeSuccess(
function_execution_id=context.function_execution_id,
outputs=outputs,
)
except Exception as e:
error = f"Failed to handle a function request (error: {{e}})"

0 comments on commit 6101d51

Please sign in to comment.