Skip to content

Commit d45c1ca

Browse files
committed
Adding test of file uploading.
1 parent 5766321 commit d45c1ca

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/data/slack_logo.png

63.2 KB
Loading

tests/test_slackrequest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
from slackclient._slackrequest import SlackRequest
22
import json
3+
import os
34

5+
def test_post_file(mocker):
6+
requests = mocker.patch('slackclient._slackrequest.requests')
7+
8+
response = SlackRequest.do('xoxb-123',
9+
'files.upload',
10+
{'file': open(os.path.join('.', 'tests', 'data', 'slack_logo.png'), 'rb'),
11+
'filename': 'slack_logo.png'})
12+
13+
assert requests.post.call_count == 1
14+
args, kwargs = requests.post.call_args
15+
assert 'https://slack.com/api/files.upload' == args[0]
16+
assert {'filename': 'slack_logo.png',
17+
'token': 'xoxb-123'} == kwargs['data']
18+
assert None != kwargs['files']
419

520
def test_post_attachements(mocker):
621
requests = mocker.patch('slackclient._slackrequest.requests')

0 commit comments

Comments
 (0)