Skip to content

Commit

Permalink
answer_back test
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavi committed Mar 11, 2024
1 parent a49869b commit 2591b70
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/lib/test_mentions_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pyxavi.url import Url
from mastofeed.lib.publisher import Publisher
from mastofeed.lib.mentions_listener import MentionParser, Mention, MentionAction
from pyxavi.mastodon_helper import StatusPostVisibility
from pyxavi.mastodon_helper import StatusPostVisibility, StatusPost
from logging import Logger as BuiltInLogger
from unittest.mock import patch, Mock
import copy
Expand Down Expand Up @@ -959,3 +959,17 @@ def test_execute(
assert saved_stuff["site_url"] == old_entry["site_url"]
assert saved_stuff["feed_url"] == old_entry["feed_url"]
assert saved_stuff["name"] == old_entry["name"]


def test_answer_back():

# Set up the mentioning environment
instance = get_mention_parser()
answer = StatusPost.from_dict({"status": "I am the answer"})
instance.answer = answer

mocked_publisher_publish = Mock()
with patch.object(instance._publisher, "publish_status_post", new=mocked_publisher_publish):
instance.answer_back()

mocked_publisher_publish.assert_called_once_with(status_post=answer)

0 comments on commit 2591b70

Please sign in to comment.