Skip to content

Commit

Permalink
Add test for scheduled statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Dec 1, 2022
1 parent d76a2ee commit 6ae2ed6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import time
import uuid

from datetime import datetime, timedelta, timezone
from os import path
from toot import CLIENT_NAME, CLIENT_WEBSITE, api, App, User
from toot.console import run_command
Expand Down Expand Up @@ -145,6 +146,17 @@ def test_post_visibility(app, user, run):
assert status["visibility"] == visibility


def test_post_scheduled(app, user, run):
scheduled_at = datetime.now(timezone.utc).replace(microsecond=0) + timedelta(minutes=10)

out = run("post", "foo", "--scheduled-at", scheduled_at.isoformat())
assert "Toot scheduled for" in out

[status] = api.scheduled_statuses(app, user)
assert status["params"]["text"] == "foo"
assert datetime.strptime(status["scheduled_at"], "%Y-%m-%dT%H:%M:%S.%f%z") == scheduled_at


def test_media_attachments(app, user, run):
assets_dir = path.realpath(path.join(path.dirname(__file__), "assets"))

Expand Down
8 changes: 8 additions & 0 deletions toot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ def fetch_status(app, user, id):
return http.get(app, user, f"/api/v1/statuses/{id}").json()


def scheduled_statuses(app, user):
"""
List scheduled statuses
https://docs.joinmastodon.org/methods/scheduled_statuses/#get
"""
return http.get(app, user, "/api/v1/scheduled_statuses").json()


def delete_status(app, user, status_id):
"""
Deletes a status with given ID.
Expand Down

0 comments on commit 6ae2ed6

Please sign in to comment.