2017-11-27 23:49:14 +01:00
|
|
|
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',
|
2018-06-04 21:20:43 +02:00
|
|
|
description="John Lennon doing a funny walk",
|
|
|
|
focus=(-0.5, 0.3))
|
|
|
|
|
2017-11-27 23:49:14 +01:00
|
|
|
assert media
|
|
|
|
|
|
|
|
status = api.status_post(
|
|
|
|
'LOL check this out',
|
2018-05-06 02:50:54 +02:00
|
|
|
media_ids=media,
|
2017-11-27 23:49:14 +01:00
|
|
|
sensitive=sensitive
|
|
|
|
)
|
|
|
|
|
|
|
|
assert status
|
|
|
|
|
|
|
|
try:
|
|
|
|
assert status['sensitive'] == sensitive
|
|
|
|
assert status['media_attachments']
|
2018-06-05 11:39:31 +02:00
|
|
|
assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk"
|
2018-06-04 21:20:43 +02:00
|
|
|
assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5
|
|
|
|
assert status['media_attachments'][0]['meta']['focus']['y'] == 0.3
|
2017-11-27 23:49:14 +01:00
|
|
|
finally:
|
|
|
|
api.status_delete(status['id'])
|
|
|
|
|
|
|
|
@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
|