Dedupe duplicate function
This commit is contained in:
parent
7793d4499a
commit
4203e8d313
4 changed files with 23 additions and 28 deletions
|
@ -15,7 +15,7 @@ def test_post(app, user, run):
|
|||
out = run("post", text)
|
||||
status_id = posted_status_id(out)
|
||||
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert text == get_text(status["content"])
|
||||
assert status["visibility"] == "public"
|
||||
assert status["sensitive"] is False
|
||||
|
@ -44,7 +44,7 @@ def test_post_visibility(app, user, run):
|
|||
for visibility in ["public", "unlisted", "private", "direct"]:
|
||||
out = run("post", "foo", "--visibility", visibility)
|
||||
status_id = posted_status_id(out)
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert status["visibility"] == visibility
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ def test_post_poll(app, user, run):
|
|||
|
||||
status_id = posted_status_id(out)
|
||||
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert status["poll"]["expired"] is False
|
||||
assert status["poll"]["multiple"] is False
|
||||
assert status["poll"]["options"] == [
|
||||
|
@ -134,7 +134,7 @@ def test_post_poll_multiple(app, user, run):
|
|||
|
||||
status_id = posted_status_id(out)
|
||||
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert status["poll"]["multiple"] is True
|
||||
|
||||
|
||||
|
@ -150,7 +150,7 @@ def test_post_poll_expires_in(app, user, run):
|
|||
|
||||
status_id = posted_status_id(out)
|
||||
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
actual = datetime.strptime(status["poll"]["expires_at"], "%Y-%m-%dT%H:%M:%S.%f%z")
|
||||
expected = datetime.now(timezone.utc) + timedelta(hours=8)
|
||||
delta = actual - expected
|
||||
|
@ -169,7 +169,7 @@ def test_post_poll_hide_totals(app, user, run):
|
|||
|
||||
status_id = posted_status_id(out)
|
||||
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
|
||||
# votes_count is None when totals are hidden
|
||||
assert status["poll"]["options"] == [
|
||||
|
@ -181,12 +181,12 @@ def test_post_poll_hide_totals(app, user, run):
|
|||
def test_post_language(app, user, run):
|
||||
out = run("post", "test", "--language", "hr")
|
||||
status_id = posted_status_id(out)
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert status["language"] == "hr"
|
||||
|
||||
out = run("post", "test", "--language", "zh")
|
||||
status_id = posted_status_id(out)
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert status["language"] == "zh"
|
||||
|
||||
|
||||
|
@ -203,7 +203,7 @@ def test_media_thumbnail(app, user, run):
|
|||
)
|
||||
|
||||
status_id = posted_status_id(out)
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
[media] = status["media_attachments"]
|
||||
|
||||
assert media["description"] == "foo"
|
||||
|
@ -241,7 +241,7 @@ def test_media_attachments(app, user, run):
|
|||
)
|
||||
|
||||
status_id = posted_status_id(out)
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
|
||||
[a1, a2, a3, a4] = status["media_attachments"]
|
||||
|
||||
|
@ -270,7 +270,7 @@ def test_media_attachment_without_text(mock_read, mock_ml, app, user, run):
|
|||
out = run("post", "--media", media_path)
|
||||
status_id = posted_status_id(out)
|
||||
|
||||
status = api.fetch_status(app, user, status_id)
|
||||
status = api.fetch_status(app, user, status_id).json()
|
||||
assert status["content"] == ""
|
||||
|
||||
[attachment] = status["media_attachments"]
|
||||
|
@ -286,7 +286,7 @@ def test_reply_thread(app, user, friend, run):
|
|||
|
||||
out = run("post", "--reply-to", status["id"], "This is the reply")
|
||||
status_id = posted_status_id(out)
|
||||
reply = api.fetch_status(app, user, status_id)
|
||||
reply = api.fetch_status(app, user, status_id).json()
|
||||
|
||||
assert reply["in_reply_to_id"] == status["id"]
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ def test_favourite(app, user, run):
|
|||
out = run("favourite", status["id"])
|
||||
assert out == "✓ Status favourited"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["favourited"]
|
||||
|
||||
out = run("unfavourite", status["id"])
|
||||
|
@ -31,7 +31,7 @@ def test_favourite(app, user, run):
|
|||
# A short delay is required before the server returns new data
|
||||
time.sleep(0.1)
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert not status["favourited"]
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ def test_reblog(app, user, run):
|
|||
out = run("reblog", status["id"])
|
||||
assert out == "✓ Status reblogged"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["reblogged"]
|
||||
|
||||
out = run("reblogged_by", status["id"])
|
||||
|
@ -51,7 +51,7 @@ def test_reblog(app, user, run):
|
|||
out = run("unreblog", status["id"])
|
||||
assert out == "✓ Status unreblogged"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert not status["reblogged"]
|
||||
|
||||
|
||||
|
@ -62,13 +62,13 @@ def test_pin(app, user, run):
|
|||
out = run("pin", status["id"])
|
||||
assert out == "✓ Status pinned"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["pinned"]
|
||||
|
||||
out = run("unpin", status["id"])
|
||||
assert out == "✓ Status unpinned"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert not status["pinned"]
|
||||
|
||||
|
||||
|
@ -79,11 +79,11 @@ def test_bookmark(app, user, run):
|
|||
out = run("bookmark", status["id"])
|
||||
assert out == "✓ Status bookmarked"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert status["bookmarked"]
|
||||
|
||||
out = run("unbookmark", status["id"])
|
||||
assert out == "✓ Status unbookmarked"
|
||||
|
||||
status = api.fetch_status(app, user, status["id"])
|
||||
status = api.fetch_status(app, user, status["id"]).json()
|
||||
assert not status["bookmarked"]
|
||||
|
|
|
@ -241,7 +241,7 @@ def fetch_status(app, user, id):
|
|||
Fetch a single status
|
||||
https://docs.joinmastodon.org/methods/statuses/#get
|
||||
"""
|
||||
return http.get(app, user, f"/api/v1/statuses/{id}").json()
|
||||
return http.get(app, user, f"/api/v1/statuses/{id}")
|
||||
|
||||
|
||||
def scheduled_statuses(app, user):
|
||||
|
@ -544,11 +544,6 @@ def verify_credentials(app, user) -> Response:
|
|||
return http.get(app, user, '/api/v1/accounts/verify_credentials')
|
||||
|
||||
|
||||
def single_status(app, user, status_id) -> Response:
|
||||
url = f"/api/v1/statuses/{status_id}"
|
||||
return http.get(app, user, url)
|
||||
|
||||
|
||||
def get_notifications(app, user, exclude_types=[], limit=20):
|
||||
params = {"exclude_types[]": exclude_types, "limit": limit}
|
||||
return http.get(app, user, '/api/v1/notifications', params).json()
|
||||
|
|
|
@ -70,7 +70,7 @@ def timeline(app, user, args, generator=None):
|
|||
|
||||
|
||||
def status(app, user, args):
|
||||
response = api.single_status(app, user, args.status_id)
|
||||
response = api.fetch_status(app, user, args.status_id)
|
||||
if args.json:
|
||||
print(response.text)
|
||||
else:
|
||||
|
@ -84,7 +84,7 @@ def thread(app, user, args):
|
|||
if args.json:
|
||||
print(context_response.text)
|
||||
else:
|
||||
toot = api.single_status(app, user, args.status_id).json()
|
||||
toot = api.fetch_status(app, user, args.status_id).json()
|
||||
context = context_response.json()
|
||||
|
||||
statuses = chain(context["ancestors"], [toot], context["descendants"])
|
||||
|
|
Loading…
Reference in a new issue