diff --git a/scripts/interop/gotosocial_interop.py b/scripts/interop/gotosocial_interop.py index 4c1a7be..1de4fcd 100644 --- a/scripts/interop/gotosocial_interop.py +++ b/scripts/interop/gotosocial_interop.py @@ -261,6 +261,15 @@ class GoToSocial: fail(f"home timeline: {status} {body}") return body + def account(self, account_id): + """The account as GoToSocial currently has it stored - not a fresh remote fetch + like resolve()'s ?resolve=true search, so this shows whether a proactive + Update(Person) actually reached and updated their cached copy.""" + status, body = api("GET", f"{GTS}/api/v1/accounts/{account_id}", self.token) + if status != 200: + fail(f"account lookup: {status} {body}") + return body + def main(): step("Getting a GoToSocial access token") @@ -372,7 +381,8 @@ def check_posts(): --now` directly in the api container (this container has no docker access to do that itself). Checks the post reaches the already-following GoToSocial account's home timeline as a private (followers-only) status with the expected text, then deletes - it and checks it disappears there too.""" + it and checks it disappears there too. Also turns now playing on and checks the + profile field GoToSocial has cached is updated by the periodic push.""" step("Getting a GoToSocial access token") gts = GoToSocial(gotosocial_token()) alice = Scrobbler() # register-or-login: the same account main() set up @@ -381,6 +391,9 @@ def check_posts(): if not gts.relationship(account_id)["following"]: fail("GoToSocial isn't following alice; run the main interop flow first") + step("Alice turns now playing on (run.sh already seeded a now-playing track)") + alice.settings(now_playing_mode="profile") + step("The weekly summary reaches GoToSocial's home timeline") posted = wait_for( "the weekly summary in GoToSocial's home timeline", @@ -405,6 +418,18 @@ def check_posts(): lambda: not any(s["id"] == posted["id"] for s in gts.home_timeline()), ) + step("The now-playing field reaches GoToSocial's cached copy of the profile") + field = wait_for( + "a Now playing field on GoToSocial's cached account", + lambda: next( + (f for f in gts.account(account_id)["fields"] if f["name"] == "Now playing"), None + ), + timeout=90, # the push is throttled and only checked every 30s + ) + if "Interop Now Playing" not in field["value"]: + fail(f"unexpected now-playing field: {field['value']!r}") + print(f" Now playing: {field['value']!r}") + step("All post interop checks passed") diff --git a/scripts/interop/run.sh b/scripts/interop/run.sh index 42e4f4a..e99cffe 100755 --- a/scripts/interop/run.sh +++ b/scripts/interop/run.sh @@ -42,19 +42,21 @@ if [ $status -ne 0 ]; then exit $status fi -echo "==> Alice scrobbles something, for the weekly summary to have content" +echo "==> Alice scrobbles something, for the weekly summary to have content, and is playing something now" "$compose" exec -T api python3 -c " from datetime import UTC, datetime from scrobbler import create_app from scrobbler.config import Config from scrobbler.extensions import db from scrobbler.models import Scrobble, User +from scrobbler.services.scrobbles import TrackInput, update_now_playing app = create_app(Config) with app.app_context(): user = db.session.scalar(db.select(User).filter_by(username='alice')) db.session.add(Scrobble(user_id=user.id, artist='Interop Artist', track='Interop Track', played_at=datetime.now(UTC))) db.session.commit() + update_now_playing(user, TrackInput(artist='Interop Artist', track='Interop Now Playing')) " echo "==> Posting alice's weekly summary immediately"