diff --git a/src/nefelibata/announcers/mastodon.py b/src/nefelibata/announcers/mastodon.py index 6829953..7ccfcc5 100644 --- a/src/nefelibata/announcers/mastodon.py +++ b/src/nefelibata/announcers/mastodon.py @@ -70,11 +70,15 @@ def announce(self, post: Post) -> str: return cast(str, toot["url"]) def collect(self, post: Post) -> List[Response]: - _logger.info(f"Collecting replies from Mastodon ({self.base_url})") + _logger.info("Collecting replies from Mastodon (%s)", self.base_url) toot_url = post.parsed[self.url_header] toot_id = toot_url.rstrip("/").rsplit("/", 1)[1] - context = self.client.status_context(toot_id) + try: + context = self.client.status_context(toot_id) + except mastodon.MastodonNotFoundError: + _logger.warning("Toot not found: %s", toot_url) + return [] responses = [] for toot in context["descendants"]: diff --git a/tests/announcers/test_fawm.py b/tests/announcers/test_fawm.py index 404f6d6..566f921 100644 --- a/tests/announcers/test_fawm.py +++ b/tests/announcers/test_fawm.py @@ -160,7 +160,8 @@ def test_get_comments_from_fawm_page(requests_mock): html = fp.read() requests_mock.get(url, text=html) - comments = get_comments_from_fawm_page(url, "username", "password") + with freeze_time("2020-12-01T00:00:00Z"): + comments = get_comments_from_fawm_page(url, "username", "password") assert comments == [ { @@ -258,7 +259,8 @@ def test_get_response_from_li(): features="html5lib", ) el = soup.html.body.li - response = get_response_from_li(url, el) + with freeze_time("2020-12-01T00:00:00Z"): + response = get_response_from_li(url, el) assert response == { "source": "FAWM", @@ -476,7 +478,8 @@ def test_announcer_extra_comments(mock_post, mocker, requests_mock): post.parsed["fawm-url"] = "https://fawm.org/songs/1" post.parsed["fawm-extra-url"] = "https://fawm.org/songs/2" - responses = announcer.collect(post) + with freeze_time("2020-12-01T00:00:00Z"): + responses = announcer.collect(post) assert responses == [ { "source": "FAWM", diff --git a/tests/test_utils.py b/tests/test_utils.py index 73c3a2f..be55ffc 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -73,7 +73,7 @@ def test_get_config_no_profile_picture(fs): "author": { "name": "Beto Dealmeida", "email": "roberto@dealmeida.net", - "profile_picture": "http://www.gravatar.com/avatar/58b573d3eac03131faee739dfc7b360a", + "profile_picture": "https://www.gravatar.com/avatar/58b573d3eac03131faee739dfc7b360a", }, "url": "http://blog.taoetc.org/", "posts-to-show": 5,