mirror of
https://github.com/ihabunek/toot
synced 2025-02-03 20:57:38 +01:00
parent
b2626a9aa8
commit
d6f5728486
@ -42,11 +42,7 @@ def test_post_defaults(mock_post, mock_uuid, capsys):
|
|||||||
'status': 'Hello world',
|
'status': 'Hello world',
|
||||||
'visibility': 'public',
|
'visibility': 'public',
|
||||||
'media_ids': [],
|
'media_ids': [],
|
||||||
'sensitive': "false",
|
'sensitive': False,
|
||||||
'spoiler_text': None,
|
|
||||||
'in_reply_to_id': None,
|
|
||||||
'language': None,
|
|
||||||
'scheduled_at': None,
|
|
||||||
}, headers={"Idempotency-Key": "rock-on"})
|
}, headers={"Idempotency-Key": "rock-on"})
|
||||||
|
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
@ -78,11 +74,10 @@ def test_post_with_options(mock_post, mock_uuid, capsys):
|
|||||||
'status': 'Hello world',
|
'status': 'Hello world',
|
||||||
'media_ids': [],
|
'media_ids': [],
|
||||||
'visibility': 'unlisted',
|
'visibility': 'unlisted',
|
||||||
'sensitive': "true",
|
'sensitive': True,
|
||||||
'spoiler_text': "Spoiler!",
|
'spoiler_text': "Spoiler!",
|
||||||
'in_reply_to_id': '123a',
|
'in_reply_to_id': '123a',
|
||||||
'language': 'hrv',
|
'language': 'hrv',
|
||||||
'scheduled_at': None,
|
|
||||||
}, headers={"Idempotency-Key": "up-the-irons"})
|
}, headers={"Idempotency-Key": "up-the-irons"})
|
||||||
|
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
|
12
toot/api.py
12
toot/api.py
@ -140,15 +140,17 @@ def post_status(
|
|||||||
'status': status,
|
'status': status,
|
||||||
'media_ids': media_ids,
|
'media_ids': media_ids,
|
||||||
'visibility': visibility,
|
'visibility': visibility,
|
||||||
'sensitive': str_bool(sensitive),
|
'sensitive': sensitive,
|
||||||
'spoiler_text': spoiler_text,
|
|
||||||
'in_reply_to_id': in_reply_to_id,
|
'in_reply_to_id': in_reply_to_id,
|
||||||
'language': language,
|
'language': language,
|
||||||
'scheduled_at': scheduled_at
|
'scheduled_at': scheduled_at,
|
||||||
|
'content_type': content_type,
|
||||||
|
'spoiler_text': spoiler_text
|
||||||
}
|
}
|
||||||
|
|
||||||
if content_type:
|
# Strip keys for which value is None
|
||||||
json['content_type'] = content_type
|
# Sending null values doesn't bother Mastodon, but it breaks Pleroma
|
||||||
|
json = {k: v for k, v in json.items() if v is not None}
|
||||||
|
|
||||||
return http.post(app, user, '/api/v1/statuses', json=json, headers=headers).json()
|
return http.post(app, user, '/api/v1/statuses', json=json, headers=headers).json()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user