X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ log_file = "logs/pytest.log"
log_file_level = "DEBUG"
log_format = "%(asctime)s %(levelname)s %(message)s"
log_date_format = "%Y-%m-%d %H:%M:%S"
filterwarnings = [
"ignore:\"@coroutine\" decorator is deprecated since Python 3.8, use \"async def\" instead:DeprecationWarning",
"ignore:The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.:DeprecationWarning",
"ignore:Unknown config option. asyncio_mode:pytest.PytestConfigWarning", # ignore warning when asyncio_mode is set but pytest-asyncio is not installed
]
filterwarnings = []
asyncio_mode = "auto"

[tool.mypy]
Expand Down
6 changes: 6 additions & 0 deletions tests/adapter_tests/django/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os

import django

os.environ["DJANGO_SETTINGS_MODULE"] = "tests.adapter_tests.django.test_django_settings"
django.setup()
2 changes: 0 additions & 2 deletions tests/adapter_tests/django/test_django.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import os
from time import time
from urllib.parse import quote

Expand Down Expand Up @@ -29,7 +28,6 @@ class TestDjango(TestCase):
base_url=mock_api_server_base_url,
)

os.environ["DJANGO_SETTINGS_MODULE"] = "tests.adapter_tests.django.test_django_settings"
rf = RequestFactory()

def setUp(self):
Expand Down
8 changes: 4 additions & 4 deletions tests/adapter_tests/starlette/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -138,7 +138,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -182,7 +182,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -254,7 +254,7 @@ async def endpoint(req: Request, foo: str = Depends(get_foo)):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down
6 changes: 3 additions & 3 deletions tests/adapter_tests/starlette/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -143,7 +143,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -189,7 +189,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down
8 changes: 4 additions & 4 deletions tests/adapter_tests_async/test_async_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -138,7 +138,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -182,7 +182,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -255,7 +255,7 @@ async def endpoint(req: Request, foo: str = Depends(get_foo)):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down
6 changes: 3 additions & 3 deletions tests/adapter_tests_async/test_async_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -143,7 +143,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down Expand Up @@ -189,7 +189,7 @@ async def endpoint(req: Request):
client = TestClient(api)
response = client.post(
"/slack/events",
data=body,
content=body,
headers=self.build_headers(timestamp, body),
)
assert response.status_code == 200
Expand Down
10 changes: 5 additions & 5 deletions tests/scenario_tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import time
from concurrent.futures import Executor
from ssl import SSLContext
import ssl

import pytest
from slack_sdk import WebClient
Expand Down Expand Up @@ -236,12 +236,12 @@ def test_none_body_no_middleware(self):
assert response.body == '{"error": "unhandled request"}'

def test_proxy_ssl_for_respond(self):
ssl = SSLContext()
ssl_context = ssl.create_default_context()
web_client = WebClient(
token=self.valid_token,
base_url=self.mock_api_server_base_url,
proxy="http://proxy-host:9000/",
ssl=ssl,
ssl=ssl_context,
)
app = App(
signing_secret="valid",
Expand All @@ -257,9 +257,9 @@ def test_proxy_ssl_for_respond(self):
@app.event("app_mention")
def handle(context: BoltContext, respond):
assert context.respond.proxy == "http://proxy-host:9000/"
assert context.respond.ssl == ssl
assert context.respond.ssl == ssl_context
assert respond.proxy == "http://proxy-host:9000/"
assert respond.ssl == ssl
assert respond.ssl == ssl_context
result["called"] = True

req = BoltRequest(body=app_mention_event_body, headers={}, mode="socket_mode")
Expand Down
4 changes: 2 additions & 2 deletions tests/scenario_tests/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ def async2(context, say):

@app.middleware
def set_ssl_context(context, next_):
from ssl import SSLContext
import ssl

context["foo"] = "FOO"
# This causes an error when starting lazy listener executions
context["ssl_context"] = SSLContext()
context["ssl_context"] = ssl.create_default_context()
next_()

# 2021-12-13 11:14:29 ERROR Failed to run a middleware middleware (error: cannot pickle 'SSLContext' object)
Expand Down
10 changes: 5 additions & 5 deletions tests/scenario_tests_async/test_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import logging
from ssl import SSLContext
import ssl

import pytest
from slack_sdk import WebClient
Expand Down Expand Up @@ -185,14 +185,14 @@ def test_installation_store_conflicts(self):

@pytest.mark.asyncio
async def test_proxy_ssl_for_respond(self):
ssl = SSLContext()
ssl_ctx = ssl.create_default_context()
app = AsyncApp(
signing_secret="valid",
client=AsyncWebClient(
token=self.valid_token,
base_url=self.mock_api_server_base_url,
proxy="http://proxy-host:9000/",
ssl=ssl,
ssl=ssl_ctx,
),
authorize=my_authorize,
)
Expand All @@ -202,9 +202,9 @@ async def test_proxy_ssl_for_respond(self):
@app.event("app_mention")
async def handle(context: AsyncBoltContext, respond):
assert context.respond.proxy == "http://proxy-host:9000/"
assert context.respond.ssl == ssl
assert context.respond.ssl == ssl_ctx
assert respond.proxy == "http://proxy-host:9000/"
assert respond.ssl == ssl
assert respond.ssl == ssl_ctx
result["called"] = True

req = AsyncBoltRequest(body=app_mention_event_body, headers={}, mode="socket_mode")
Expand Down
4 changes: 2 additions & 2 deletions tests/scenario_tests_async/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ async def async2(context, say):

@app.middleware
async def set_ssl_context(context, next_):
from ssl import SSLContext
import ssl

context["foo"] = "FOO"
# This causes an error when starting lazy listener executions
context["ssl_context"] = SSLContext()
context["ssl_context"] = ssl.create_default_context()
await next_()

# 2021-12-13 11:52:46 ERROR Failed to run a middleware function (error: cannot pickle 'SSLContext' object)
Expand Down
Loading
X Tutup