1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import pytest
@pytest.mark.vcr(match_on=['path'])
@pytest.mark.parametrize('sensitive', (False, True))
def test_media_post(api, sensitive):
media = api.media_post(
'tests/image.jpg',
description="John Lennon doing a funny walk",
focus=(-0.5, 0.3))
assert media
status = api.status_post(
'LOL check this out',
media_ids=media,
sensitive=sensitive
)
assert status
try:
assert status['sensitive'] == sensitive
assert status['media_attachments']
assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk"
assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5
assert status['media_attachments'][0]['meta']['focus']['y'] == 0.3
finally:
api.status_delete(status['id'])
@pytest.mark.vcr(match_on=['path'])
def test_media_update(api):
media = api.media_post(
'tests/image.jpg',
description="John Lennon doing a funny walk",
focus=(-0.5, 0.3))
assert media
media_up = api.media_update(
media,
description="John Lennon doing a cool walk",
focus=(0.69, 0.69))
assert media_up
assert media_up['description'] == "John Lennon doing a cool walk"
assert media_up['meta']['focus']['x'] == 0.69
assert media_up['meta']['focus']['y'] == 0.69
@pytest.mark.vcr(match_on=['path'])
def test_media_post_file(api):
with open('tests/image.jpg', 'rb') as f:
media = api.media_post(f, mime_type='image/jpeg')
assert media
|