aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-08 23:24:42 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-08 23:24:42 +0200
commitd0b1da993d4a38469106d6bd52dab6254bbd0053 (patch)
tree5ec0bf85db3f0a67f7668b18d741c785ffda1036 /tests/test_media.py
parent3277ca777821e76955fb26d80788939a311db9db (diff)
downloadmastodon.py-d0b1da993d4a38469106d6bd52dab6254bbd0053.tar.gz
add media v2 API + tests, move v1 test
Diffstat (limited to 'tests/test_media.py')
-rw-r--r--tests/test_media.py76
1 files changed, 73 insertions, 3 deletions
diff --git a/tests/test_media.py b/tests/test_media.py
index f2c3b2f..4de654f 100644
--- a/tests/test_media.py
+++ b/tests/test_media.py
@@ -1,18 +1,53 @@
1import pytest 1import pytest
2import vcr
3import time
4
5@pytest.mark.vcr(match_on=['path'])
6def test_media_post_v1(api):
7 with vcr.use_cassette('test_media_post.yaml', cassette_library_dir='tests/cassettes_pre_4_0_0', record_mode='none'):
8 media = api.media_post(
9 'tests/image.jpg',
10 description="John Lennon doing a funny walk",
11 focus=(-0.5, 0.3))
12
13 assert media
14
15 status = api.status_post(
16 'LOL check this out',
17 media_ids=media,
18 sensitive=False
19 )
20
21 assert status
22
23 try:
24 assert status['sensitive'] == False
25 assert status['media_attachments']
26 assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk"
27 assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5
28 assert status['media_attachments'][0]['meta']['focus']['y'] == 0.3
29 finally:
30 api.status_delete(status['id'])
2 31
3@pytest.mark.vcr(match_on=['path']) 32@pytest.mark.vcr(match_on=['path'])
4@pytest.mark.parametrize('sensitive', (False, True)) 33@pytest.mark.parametrize('sensitive', (False, True))
5def test_media_post(api, sensitive): 34def test_media_post(api, sensitive):
6 media = api.media_post( 35 media = api.media_post(
7 'tests/image.jpg', 36 'tests/video.mp4',
8 description="John Lennon doing a funny walk", 37 description="me when a cat",
9 focus=(-0.5, 0.3)) 38 focus=(-0.5, 0.3))
10 39
11 assert media 40 assert media
41 assert media.url is None
42
43 time.sleep(10)
44 media2 = api.media(media)
45 assert media2.id == media.id
46 assert not media2.url is None
12 47
13 status = api.status_post( 48 status = api.status_post(
14 'LOL check this out', 49 'LOL check this out',
15 media_ids=media, 50 media_ids=media2,
16 sensitive=sensitive 51 sensitive=sensitive
17 ) 52 )
18 53
@@ -21,9 +56,44 @@ def test_media_post(api, sensitive):
21 try: 56 try:
22 assert status['sensitive'] == sensitive 57 assert status['sensitive'] == sensitive
23 assert status['media_attachments'] 58 assert status['media_attachments']
59 assert status['media_attachments'][0]['description'] == "me when a cat"
60 assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5
61 assert status['media_attachments'][0]['meta']['focus']['y'] == 0.3
62 finally:
63 api.status_delete(status['id'])
64
65def test_media_post_multiple(api):
66 media = api.media_post(
67 'tests/image.jpg',
68 description="John Lennon doing a funny walk",
69 focus=(-0.5, 0.3),
70 synchronous=True)
71 media2 = api.media_post(
72 'tests/amewatson.jpg',
73 description="hololives #1 detective, watson ameliachan",
74 focus=(0.5, 0.5),
75 synchronous=True)
76
77 assert media
78 assert media.url is not None
79 assert media2
80 assert media2.url is not None
81
82 status = api.status_post(
83 'LOL check this out',
84 media_ids=[media, media2.id],
85 )
86
87 assert status
88
89 try:
90 assert status['media_attachments']
24 assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk" 91 assert status['media_attachments'][0]['description'] == "John Lennon doing a funny walk"
25 assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5 92 assert status['media_attachments'][0]['meta']['focus']['x'] == -0.5
26 assert status['media_attachments'][0]['meta']['focus']['y'] == 0.3 93 assert status['media_attachments'][0]['meta']['focus']['y'] == 0.3
94 assert status['media_attachments'][1]['description'] == "hololives #1 detective, watson ameliachan"
95 assert status['media_attachments'][1]['meta']['focus']['x'] == 0.5
96 assert status['media_attachments'][1]['meta']['focus']['y'] == 0.5
27 finally: 97 finally:
28 api.status_delete(status['id']) 98 api.status_delete(status['id'])
29 99
Powered by cgit v1.2.3 (git 2.41.0)