diff options
author | codl <[email protected]> | 2017-11-27 23:49:14 +0100 |
---|---|---|
committer | codl <[email protected]> | 2017-11-27 23:49:14 +0100 |
commit | 38f99480dbeb6222ff8102163cfeca64634217a5 (patch) | |
tree | 38d24aeb106556cb25a48f69ab5c1eeddc49adbf /tests/test_media.py | |
parent | c73fd26729e8266374bc89f50cae5c429bf6122e (diff) | |
download | mastodon.py-38f99480dbeb6222ff8102163cfeca64634217a5.tar.gz |
add tests for media
Diffstat (limited to 'tests/test_media.py')
-rw-r--r-- | tests/test_media.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_media.py b/tests/test_media.py new file mode 100644 index 0000000..b1cfd89 --- /dev/null +++ b/tests/test_media.py | |||
@@ -0,0 +1,31 @@ | |||
1 | import pytest | ||
2 | |||
3 | @pytest.mark.vcr(match_on=['path']) | ||
4 | @pytest.mark.parametrize('sensitive', (False, True)) | ||
5 | def test_media_post(api, sensitive): | ||
6 | media = api.media_post( | ||
7 | 'tests/image.jpg', | ||
8 | description="John Lennon doing a funny walk") | ||
9 | |||
10 | assert media | ||
11 | |||
12 | status = api.status_post( | ||
13 | 'LOL check this out', | ||
14 | media_ids=[media], | ||
15 | sensitive=sensitive | ||
16 | ) | ||
17 | |||
18 | assert status | ||
19 | |||
20 | try: | ||
21 | assert status['sensitive'] == sensitive | ||
22 | assert status['media_attachments'] | ||
23 | assert status['media_attachments'][0]['description'] | ||
24 | finally: | ||
25 | api.status_delete(status['id']) | ||
26 | |||
27 | @pytest.mark.vcr(match_on=['path']) | ||
28 | def test_media_post_file(api): | ||
29 | with open('tests/image.jpg', 'rb') as f: | ||
30 | media = api.media_post(f, mime_type='image/jpeg') | ||
31 | assert media | ||