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
50 changes: 50 additions & 0 deletions integration_tests/web/test_issue_670.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import asyncio
import io
import logging
import os
import unittest

from integration_tests.env_variable_names import SLACK_SDK_TEST_BOT_TOKEN
from integration_tests.helpers import async_test
from slack import WebClient


class TestWebClient(unittest.TestCase):
"""Runs integration tests with real Slack API

https://github.com/slackapi/python-slackclient/issues/670
"""

def setUp(self):
self.logger = logging.getLogger(__name__)
self.bot_token = os.environ[SLACK_SDK_TEST_BOT_TOKEN]
self.sync_client: WebClient = WebClient(token=self.bot_token, run_async=False, loop=asyncio.new_event_loop())
self.async_client: WebClient = WebClient(token=self.bot_token, run_async=True)

def tearDown(self):
pass

def test_issue_670(self):
client = self.sync_client
buff = io.BytesIO(b'here is my data but not sure what is wrong.......')
buff.seek(0)
upload = client.files_upload(
file=buff,
filename="output.text",
filetype="text",
title=None,
)
self.assertIsNotNone(upload)

@async_test
async def test_issue_670_async(self):
client = self.async_client
buff = io.BytesIO(b'here is my data but not sure what is wrong.......')
buff.seek(0)
upload = await client.files_upload(
file=buff,
filename="output.text",
filetype="text",
title=None,
)
self.assertIsNotNone(upload)
7 changes: 7 additions & 0 deletions slack/web/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ def api_call(
if auth:
auth = BasicAuth(auth["client_id"], auth["client_secret"])

if data:
data = {k: v for k, v in data.items() if v is not None}
if files:
files = {k: v for k, v in files.items() if v is not None}
if params:
params = {k: v for k, v in params.items() if v is not None}

req_args = {
"headers": self._get_headers(has_json, has_files, headers),
"data": data,
Expand Down