kopia lustrzana https://github.com/ihabunek/toot
Remove use of deprecated status.text_url
rodzic
e396768d15
commit
7b4063fddc
|
@ -293,13 +293,14 @@ def test_reblogged_by(mock_get, monkeypatch, capsys):
|
||||||
])
|
])
|
||||||
assert out == expected
|
assert out == expected
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('toot.http.post')
|
@mock.patch('toot.http.post')
|
||||||
def test_upload(mock_post, capsys):
|
def test_upload(mock_post, capsys):
|
||||||
mock_post.return_value = MockResponse({
|
mock_post.return_value = MockResponse({
|
||||||
'id': 123,
|
'id': 123,
|
||||||
'url': 'https://bigfish.software/123/456',
|
'url': 'https://bigfish.software/123/456',
|
||||||
'preview_url': 'https://bigfish.software/789/012',
|
'preview_url': 'https://bigfish.software/789/012',
|
||||||
'text_url': 'https://bigfish.software/345/678',
|
'url': 'https://bigfish.software/345/678',
|
||||||
'type': 'image',
|
'type': 'image',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ from toot import CLIENT_NAME, CLIENT_WEBSITE, api, App, User
|
||||||
from toot.console import run_command
|
from toot.console import run_command
|
||||||
from toot.exceptions import ConsoleError, NotFoundError
|
from toot.exceptions import ConsoleError, NotFoundError
|
||||||
from toot.utils import get_text
|
from toot.utils import get_text
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
# Host name of a test instance to run integration tests against
|
# Host name of a test instance to run integration tests against
|
||||||
# DO NOT USE PUBLIC INSTANCES!!!
|
# DO NOT USE PUBLIC INSTANCES!!!
|
||||||
|
@ -181,6 +182,27 @@ def test_media_attachments(app, user, run):
|
||||||
assert a4["description"] == "Test 4"
|
assert a4["description"] == "Test 4"
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch("toot.utils.multiline_input")
|
||||||
|
@mock.patch("sys.stdin.read")
|
||||||
|
def test_media_attachment_without_text(mock_read, mock_ml, app, user, run):
|
||||||
|
# No status from stdin or readline
|
||||||
|
mock_read.return_value = ""
|
||||||
|
mock_ml.return_value = ""
|
||||||
|
|
||||||
|
assets_dir = path.realpath(path.join(path.dirname(__file__), "assets"))
|
||||||
|
media_path = path.join(assets_dir, "test1.png")
|
||||||
|
|
||||||
|
out = run("post", "--media", media_path)
|
||||||
|
status_id = _posted_status_id(out)
|
||||||
|
|
||||||
|
status = api.fetch_status(app, user, status_id)
|
||||||
|
assert status["content"] == ""
|
||||||
|
|
||||||
|
[attachment] = status["media_attachments"]
|
||||||
|
assert attachment["meta"]["original"]["size"] == "50x50"
|
||||||
|
assert attachment["description"] is None
|
||||||
|
|
||||||
|
|
||||||
def test_delete_status(app, user, run):
|
def test_delete_status(app, user, run):
|
||||||
status = api.post_status(app, user, "foo")
|
status = api.post_status(app, user, "foo")
|
||||||
|
|
||||||
|
|
|
@ -100,15 +100,16 @@ def post(app, user, args):
|
||||||
media_ids = [m["id"] for m in uploaded_media]
|
media_ids = [m["id"] for m in uploaded_media]
|
||||||
|
|
||||||
if uploaded_media and not args.text:
|
if uploaded_media and not args.text:
|
||||||
args.text = "\n".join(m['text_url'] for m in uploaded_media)
|
args.text = "\n".join(m['url'] for m in uploaded_media)
|
||||||
|
|
||||||
if args.editor:
|
if sys.stdin.isatty():
|
||||||
args.text = editor_input(args.editor, args.text)
|
if args.editor:
|
||||||
elif not args.text:
|
args.text = editor_input(args.editor, args.text)
|
||||||
print_out("Write or paste your toot. Press <yellow>{}</yellow> to post it.".format(EOF_KEY))
|
elif not args.text:
|
||||||
args.text = multiline_input()
|
print_out("Write or paste your toot. Press <yellow>{}</yellow> to post it.".format(EOF_KEY))
|
||||||
|
args.text = multiline_input()
|
||||||
|
|
||||||
if not args.text:
|
if not args.text and not uploaded_media:
|
||||||
raise ConsoleError("You must specify either text or media to post.")
|
raise ConsoleError("You must specify either text or media to post.")
|
||||||
|
|
||||||
response = api.post_status(
|
response = api.post_status(
|
||||||
|
@ -232,9 +233,8 @@ def upload(app, user, args):
|
||||||
|
|
||||||
print_out()
|
print_out()
|
||||||
print_out(msg.format(response['id'], response['type']))
|
print_out(msg.format(response['id'], response['type']))
|
||||||
print_out("Original URL: <green>{}</green>".format(response['url']))
|
print_out("URL: <green>{}</green>".format(response['url']))
|
||||||
print_out("Preview URL: <green>{}</green>".format(response['preview_url']))
|
print_out("Preview URL: <green>{}</green>".format(response['preview_url']))
|
||||||
print_out("Text URL: <green>{}</green>".format(response['text_url']))
|
|
||||||
|
|
||||||
|
|
||||||
def search(app, user, args):
|
def search(app, user, args):
|
||||||
|
|
|
@ -196,7 +196,7 @@ def print_status(status, width):
|
||||||
if media_attachments:
|
if media_attachments:
|
||||||
print_out("\nMedia:")
|
print_out("\nMedia:")
|
||||||
for attachment in media_attachments:
|
for attachment in media_attachments:
|
||||||
url = attachment['text_url'] or attachment['url']
|
url = attachment["url"]
|
||||||
for line in wc_wrap(url, width):
|
for line in wc_wrap(url, width):
|
||||||
print_out(line)
|
print_out(line)
|
||||||
|
|
||||||
|
|
|
@ -274,8 +274,7 @@ class StatusDetails(urwid.Pile):
|
||||||
yield ("pack", urwid.Text([("bold", "Media attachment"), " (", m["type"], ")"]))
|
yield ("pack", urwid.Text([("bold", "Media attachment"), " (", m["type"], ")"]))
|
||||||
if m["description"]:
|
if m["description"]:
|
||||||
yield ("pack", urwid.Text(m["description"]))
|
yield ("pack", urwid.Text(m["description"]))
|
||||||
url = m.get("text_url") or m["url"]
|
yield ("pack", urwid.Text(("link", m["url"])))
|
||||||
yield ("pack", urwid.Text(("link", url)))
|
|
||||||
|
|
||||||
poll = status.data.get("poll")
|
poll = status.data.get("poll")
|
||||||
if poll:
|
if poll:
|
||||||
|
|
Ładowanie…
Reference in New Issue