pymastodon/tests/test_statuses.py

43 lines
1.2 KiB
Python
Raw Normal View History

from mastodon.application import MastodonApplication
from mastodon.timelines import Timelines
from mastodon.model.status import Status
from loguru import logger
import json
import pytest
from responses import matchers
import responses
@pytest.fixture
def app():
yield MastodonApplication("pymastodon")
@responses.activate
def test_favourite(app):
responses.post("https://social.example.com/api/v1/statuses/1234/favourite", json=json_reader("./tests/resources/favourite_response.json"))
response = app.statuses.favourite("1234")
assert response is not None
try:
status = Status.model_validate(response)
assert status.favourited == True
except Exception as ve:
logger.debug(response)
logger.error(ve)
@responses.activate
2024-05-03 08:46:24 +02:00
def test_reblog(app):
responses.post("https://social.example.com/api/v1/statuses/1234/reblog", json=json_reader("./tests/resources/reblog_response.json"))
response = app.statuses.reblog("1234")
assert response is not None
try:
status = Status.model_validate(response)
assert status.reblogged == True
except Exception as ve:
logger.debug(response)
logger.error(ve)
def json_reader(path):
with open(path) as f:
return json.load(f)