From 38f99480dbeb6222ff8102163cfeca64634217a5 Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 23:49:14 +0100 Subject: add tests for media --- tests/test_media.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/test_media.py (limited to 'tests/test_media.py') 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 @@ +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") + + 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'] + 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 -- cgit v1.2.3