Fix several tests when running on Pleroma

This commit is contained in:
Ivan Habunek 2022-12-07 15:01:30 +01:00
parent 3e828c05d9
commit 40e7a6f3a1
No known key found for this signature in database
GPG key ID: CDBD63C43A30BB95

View file

@ -25,7 +25,6 @@ from os import path
from toot import CLIENT_NAME, CLIENT_WEBSITE, api, App, User
from toot.console import run_command
from toot.exceptions import ConsoleError, NotFoundError
from toot.tui.utils import parse_datetime
from toot.utils import get_text
from unittest import mock
@ -131,13 +130,15 @@ def test_post(app, user, run):
status = api.fetch_status(app, user, status_id)
assert text == get_text(status["content"])
assert status["account"]["acct"] == user.username
assert status["application"]["name"] == CLIENT_NAME
assert status["application"]["website"] == CLIENT_WEBSITE
assert status["visibility"] == "public"
assert status["sensitive"] is False
assert status["spoiler_text"] == ""
# Pleroma doesn't return the application
if status["application"]:
assert status["application"]["name"] == CLIENT_NAME
assert status["application"]["website"] == CLIENT_WEBSITE
def test_post_visibility(app, user, run):
for visibility in ["public", "unlisted", "private", "direct"]:
@ -217,10 +218,12 @@ def test_media_attachments(app, user, run):
[a1, a2, a3, a4] = status["media_attachments"]
assert a1["meta"]["original"]["size"] == "50x50"
assert a2["meta"]["original"]["size"] == "50x60"
assert a3["meta"]["original"]["size"] == "50x70"
assert a4["meta"]["original"]["size"] == "50x80"
# Pleroma doesn't send metadata
if "meta" in a1:
assert a1["meta"]["original"]["size"] == "50x50"
assert a2["meta"]["original"]["size"] == "50x60"
assert a3["meta"]["original"]["size"] == "50x70"
assert a4["meta"]["original"]["size"] == "50x80"
assert a1["description"] == "Test 1"
assert a2["description"] == "Test 2"
@ -245,8 +248,11 @@ def test_media_attachment_without_text(mock_read, mock_ml, app, user, run):
assert status["content"] == ""
[attachment] = status["media_attachments"]
assert attachment["meta"]["original"]["size"] == "50x50"
assert attachment["description"] is None
assert not attachment["description"]
# Pleroma doesn't send metadata
if "meta" in attachment:
assert attachment["meta"]["original"]["size"] == "50x50"
def test_delete_status(app, user, run):
@ -418,7 +424,7 @@ def strip_ansi(string):
def _posted_status_id(out):
pattern = re.compile(r"Toot posted: http://([^/]+)/@([^/]+)/(.+)")
pattern = re.compile(r"Toot posted: http://([^/]+)/([^/]+)/(.+)")
match = re.search(pattern, out)
assert match