-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy pathtest_async_complete.py
More file actions
49 lines (38 loc) · 1.68 KB
/
test_async_complete.py
File metadata and controls
49 lines (38 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import pytest
import asyncio
from slack_sdk.web.async_client import AsyncWebClient
from slack_bolt.context.complete.async_complete import AsyncComplete
from tests.mock_web_api_server import (
setup_mock_web_api_server,
cleanup_mock_web_api_server,
)
class TestAsyncComplete:
@pytest.fixture
def event_loop(self):
setup_mock_web_api_server(self)
valid_token = "xoxb-valid"
mock_api_server_base_url = "http://localhost:8888"
self.web_client = AsyncWebClient(token=valid_token, base_url=mock_api_server_base_url)
loop = asyncio.get_event_loop()
yield loop
loop.close()
cleanup_mock_web_api_server(self)
@pytest.mark.asyncio
async def test_complete(self):
complete_success = AsyncComplete(client=self.web_client, function_execution_id="fn1111")
response = await complete_success(outputs={"key": "value"})
assert response.status_code == 200
@pytest.mark.asyncio
async def test_complete_no_function_execution_id(self):
complete = AsyncComplete(client=self.web_client, function_execution_id=None)
with pytest.raises(ValueError):
await complete(outputs={"key": "value"})
@pytest.mark.asyncio
async def test_has_been_called_false_initially(self):
complete = AsyncComplete(client=self.web_client, function_execution_id="fn1111")
assert complete.has_been_called() is False
@pytest.mark.asyncio
async def test_has_been_called_true_after_complete(self):
complete = AsyncComplete(client=self.web_client, function_execution_id="fn1111")
await complete(outputs={"key": "value"})
assert complete.has_been_called() is True