Skip to content

Commit 5292784

Browse files
committed
test /api
1 parent 2f4257a commit 5292784

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

tests/slack_sdk/web/test_legacy_web_client_url_format.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def setUp(self):
1010
setup_mock_web_api_server(self, MockHandler)
1111
self.client = LegacyWebClient(token="xoxb-api_test", base_url="http://localhost:8888")
1212
self.client_base_url_slash = LegacyWebClient(token="xoxb-api_test", base_url="http://localhost:8888/")
13+
self.client_api = LegacyWebClient(token="xoxb-api_test", base_url="http://localhost:8888/api")
14+
self.client_api_slash = LegacyWebClient(token="xoxb-api_test", base_url="http://localhost:8888/api/")
1315

1416
def tearDown(self):
1517
cleanup_mock_web_api_server(self)
@@ -33,3 +35,19 @@ def test_base_url_with_slash_api_method_with_slash(self):
3335
def test_base_url_without_slash_api_method_with_slash_and_trailing_slash(self):
3436
self.client.api_call("/chat.postMessage/")
3537
assert_received_request_count(self, "/chat.postMessage/", 1)
38+
39+
def test_base_url_with_api(self):
40+
self.client_api.api_call("chat.postMessage")
41+
assert_received_request_count(self, "/api/chat.postMessage", 1)
42+
43+
def test_base_url_with_api_method_without_slash_method_with_slash(self):
44+
self.client_api.api_call("/chat.postMessage")
45+
assert_received_request_count(self, "/api/chat.postMessage", 1)
46+
47+
def test_base_url_with_api_slash(self):
48+
self.client_api_slash.api_call("chat.postMessage")
49+
assert_received_request_count(self, "/api/chat.postMessage", 1)
50+
51+
def test_base_url_with_api_slash_and_method_with_slash(self):
52+
self.client_api_slash.api_call("/chat.postMessage")
53+
assert_received_request_count(self, "/api/chat.postMessage", 1)

tests/slack_sdk/web/test_web_client_url_format.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ def setUp(self):
1010
setup_mock_web_api_server(self, MockHandler)
1111
self.client = WebClient(token="xoxb-api_test", base_url="http://localhost:8888")
1212
self.client_base_url_slash = WebClient(token="xoxb-api_test", base_url="http://localhost:8888/")
13+
self.client_api = WebClient(token="xoxb-api_test", base_url="http://localhost:8888/api")
14+
self.client_api_slash = WebClient(token="xoxb-api_test", base_url="http://localhost:8888/api/")
1315

1416
def tearDown(self):
1517
cleanup_mock_web_api_server(self)
@@ -33,3 +35,19 @@ def test_base_url_with_slash_api_method_with_slash(self):
3335
def test_base_url_without_slash_api_method_with_slash_and_trailing_slash(self):
3436
self.client.api_call("/chat.postMessage/")
3537
assert_received_request_count(self, "/chat.postMessage/", 1)
38+
39+
def test_base_url_with_api(self):
40+
self.client_api.api_call("chat.postMessage")
41+
assert_received_request_count(self, "/api/chat.postMessage", 1)
42+
43+
def test_base_url_with_api_method_with_slash(self):
44+
self.client_api.api_call("/chat.postMessage")
45+
assert_received_request_count(self, "/api/chat.postMessage", 1)
46+
47+
def test_base_url_with_api_slash(self):
48+
self.client_api_slash.api_call("chat.postMessage")
49+
assert_received_request_count(self, "/api/chat.postMessage", 1)
50+
51+
def test_base_url_with_api_slash_and_method_with_slash(self):
52+
self.client_api_slash.api_call("/chat.postMessage")
53+
assert_received_request_count(self, "/api/chat.postMessage", 1)

tests/slack_sdk_async/web/test_web_client_url_format.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def setUp(self):
1515
setup_mock_web_api_server_async(self, MockHandler)
1616
self.client = AsyncWebClient(token="xoxb-api_test", base_url="http://localhost:8888")
1717
self.client_base_url_slash = AsyncWebClient(token="xoxb-api_test", base_url="http://localhost:8888/")
18+
self.client_api = AsyncWebClient(token="xoxb-api_test", base_url="http://localhost:8888/api")
19+
self.client_api_slash = AsyncWebClient(token="xoxb-api_test", base_url="http://localhost:8888/api/")
1820

1921
def tearDown(self):
2022
cleanup_mock_web_api_server_async(self)
@@ -43,3 +45,23 @@ async def test_base_url_with_slash_api_method_with_slash(self):
4345
async def test_base_url_without_slash_api_method_with_slash_and_trailing_slash(self):
4446
await self.client.api_call("/chat.postMessage/")
4547
await assert_received_request_count_async(self, "/chat.postMessage/", 1)
48+
49+
@async_test
50+
async def test_base_url_with_api(self):
51+
await self.client_api.api_call("chat.postMessage")
52+
assert_received_request_count_async(self, "/api/chat.postMessage", 1)
53+
54+
@async_test
55+
async def test_base_url_with_api_method_without_slash_method_with_slash(self):
56+
await self.client_api.api_call("/chat.postMessage")
57+
assert_received_request_count_async(self, "/api/chat.postMessage", 1)
58+
59+
@async_test
60+
async def test_base_url_with_api_slash(self):
61+
await self.client_api_slash.api_call("chat.postMessage")
62+
await assert_received_request_count_async(self, "/api/chat.postMessage", 1)
63+
64+
@async_test
65+
async def test_base_url_with_api_slash_and_method_with_slash(self):
66+
await self.client_api_slash.api_call("/chat.postMessage")
67+
await assert_received_request_count_async(self, "/api/chat.postMessage", 1)

0 commit comments

Comments
 (0)