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 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)