diff --git a/src/feditest/nodedrivers/fallback/fediverse.py b/src/feditest/nodedrivers/fallback/fediverse.py index f9fce3b..f45b577 100644 --- a/src/feditest/nodedrivers/fallback/fediverse.py +++ b/src/feditest/nodedrivers/fallback/fediverse.py @@ -153,6 +153,13 @@ def like_object(self, actor_acct_uri: str, object_uri: str) -> None: + ' and hit return when done.') + # Python 3.12 @override + def unlike_object(self, actor_acct_uri: str, object_uri: str) -> None: + prompt_user( + f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" unlike the object at "{ object_uri }"' + + ' and hit return when done.') + + # Python 3.12 @override def announce_object(self, actor_acct_uri: str, object_uri: str) -> None: prompt_user( @@ -160,6 +167,13 @@ def announce_object(self, actor_acct_uri: str, object_uri: str) -> None: + ' and hit return when done.') + # Python 3.12 @override + def unannounce_object(self, actor_acct_uri: str, object_uri: str) -> None: + prompt_user( + f'On FediverseNode "{ self.hostname }", make actor "{ actor_acct_uri }" unannounce/undo reblog/undo boost the object at "{ object_uri }"' + + ' and hit return when done.') + + # Python 3.12 @override def actor_has_received_object(self, actor_acct_uri: str, object_uri: str) -> str | None: answer = prompt_user( diff --git a/src/feditest/nodedrivers/mastodon/__init__.py b/src/feditest/nodedrivers/mastodon/__init__.py index 911bb88..f049fc8 100644 --- a/src/feditest/nodedrivers/mastodon/__init__.py +++ b/src/feditest/nodedrivers/mastodon/__init__.py @@ -321,6 +321,14 @@ def like_object(self, object_uri: str) -> None: raise ValueError(f'Cannot find Note on { self }: "{ object_uri }"') + def unlike_object(self, object_uri: str) -> None: + if note := self._find_note_dict_by_uri(object_uri): + note_id = note['id'] + response = self.http_post(f'/api/v1/statuses/{ note_id }/unfavourite') + return response + raise ValueError(f'Cannot find Note on { self }: "{ object_uri }"') + + def announce_object(self, object_uri: str) -> None: if note := self._find_note_dict_by_uri(object_uri): note_id = note['id'] @@ -329,6 +337,14 @@ def announce_object(self, object_uri: str) -> None: raise ValueError(f'Cannot find Note on { self }: "{ object_uri }"') + def unannounce_object(self, object_uri: str) -> None: + if note := self._find_note_dict_by_uri(object_uri): + note_id = note['id'] + response = self.http_post(f'/api/v1/statuses/{ note_id }/unreblog') + return response + raise ValueError(f'Cannot find Note on { self }: "{ object_uri }"') + + def actor_has_received_object(self, object_uri: str) -> dict[str, Any]: # Depending on how the Note is addressed and follow status, Mastodon puts it into the Home timeline or only # into notifications. @@ -690,6 +706,13 @@ def like_object(self, actor_acct_uri: str, object_uri: str) -> None: self._run_poor_mans_cron() + # Python 3.12 @override + def unlike_object(self, actor_acct_uri: str, object_uri: str) -> None: + mastodon_client = self._get_mastodon_client_by_actor_acct_uri(actor_acct_uri) + mastodon_client.unlike_object(object_uri) + self._run_poor_mans_cron() + + # Python 3.12 @override def announce_object(self, actor_acct_uri: str, object_uri: str) -> None: mastodon_client = self._get_mastodon_client_by_actor_acct_uri(actor_acct_uri) @@ -697,6 +720,13 @@ def announce_object(self, actor_acct_uri: str, object_uri: str) -> None: self._run_poor_mans_cron() + # Python 3.12 @override + def unannounce_object(self, actor_acct_uri: str, object_uri: str) -> None: + mastodon_client = self._get_mastodon_client_by_actor_acct_uri(actor_acct_uri) + mastodon_client.unannounce_object(object_uri) + self._run_poor_mans_cron() + + # Python 3.12 @override def actor_has_received_object(self, actor_acct_uri: str, object_uri: str) -> str | None: mastodon_client = self._get_mastodon_client_by_actor_acct_uri(actor_acct_uri) diff --git a/src/feditest/protocols/fediverse/__init__.py b/src/feditest/protocols/fediverse/__init__.py index 3d82da9..23aa529 100644 --- a/src/feditest/protocols/fediverse/__init__.py +++ b/src/feditest/protocols/fediverse/__init__.py @@ -237,6 +237,13 @@ def like_object(self, actor_acct_uri: str, object_uri: str) -> None: raise NotImplementedByNodeError(self, FediverseNode.like_object) + def unlike_object(self, actor_acct_uri: str, object_uri: str) -> None: + """ + Unlike an object (like a note) that was previously liked + """ + raise NotImplementedByNodeError(self, FediverseNode.unlike_object) + + def announce_object(self, actor_acct_uri: str, object_uri: str) -> None: """ Announce an object (boost, reblog). @@ -244,6 +251,13 @@ def announce_object(self, actor_acct_uri: str, object_uri: str) -> None: raise NotImplementedByNodeError(self, FediverseNode.announce_object) + def unannounce_object(self, actor_acct_uri: str, object_uri: str) -> None: + """ + Undo a previous announce of an object (boost, reblog). + """ + raise NotImplementedByNodeError(self, FediverseNode.unannounce_object) + + def actor_has_received_object(self, actor_acct_uri: str, object_uri: str) -> str | None: """ If the object at object_uri has arrived with the Actor at actor_acct_uri, return the content