Skip to content

Commit

Permalink
Fix several tests when running on Pleroma
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Dec 7, 2022
1 parent 3e828c0 commit 40e7a6f
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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

Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -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"
Expand All @@ -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):
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 40e7a6f

Please sign in to comment.