From 6f41e5f4078495bc27f2fb027fab7b1856623599 Mon Sep 17 00:00:00 2001 From: dece Date: Sat, 26 Aug 2023 18:25:13 +0200 Subject: [PATCH] clean --- edmond/plugins/playlist_of_the_day.py | 4 +++- edmond/plugins/tests/test_sleep.py | 1 - edmond/plugins/tests/test_wikipedia.py | 14 -------------- edmond/plugins/wikipedia.py | 1 + 4 files changed, 4 insertions(+), 16 deletions(-) delete mode 100644 edmond/plugins/tests/test_wikipedia.py diff --git a/edmond/plugins/playlist_of_the_day.py b/edmond/plugins/playlist_of_the_day.py index 44d5cf5..219a907 100644 --- a/edmond/plugins/playlist_of_the_day.py +++ b/edmond/plugins/playlist_of_the_day.py @@ -90,11 +90,12 @@ class PlaylistOfTheDayPlugin(Plugin): today.isoformat(), ) - def post_playlist(self, target): + def post_playlist(self, target: str) -> None: playlist: list[str] = self.get_storage_value(self.PLAYLIST_KEY, []) if not playlist: self.bot.log_e("Playlist empty.") self.signal_failure(target) + return linkified_items = map(PlaylistOfTheDayPlugin.linkify, playlist) html_items = map(lambda item: f"
  • {item}
  • ", linkified_items) @@ -104,6 +105,7 @@ class PlaylistOfTheDayPlugin(Plugin): if not url: self.bot.log_e("Shrlok returned None.") self.signal_failure(target) + return date = self.get_storage_value(self.DATE_KEY, "") if date != datetime.date.today().isoformat(): diff --git a/edmond/plugins/tests/test_sleep.py b/edmond/plugins/tests/test_sleep.py index 6851ca0..ecbc26b 100644 --- a/edmond/plugins/tests/test_sleep.py +++ b/edmond/plugins/tests/test_sleep.py @@ -1,6 +1,5 @@ import unittest from datetime import datetime, timedelta -from unittest.mock import Mock, patch from edmond.tests.test_plugin import get_plugin_patcher from ..sleep import SleepPlugin diff --git a/edmond/plugins/tests/test_wikipedia.py b/edmond/plugins/tests/test_wikipedia.py deleted file mode 100644 index 44bd753..0000000 --- a/edmond/plugins/tests/test_wikipedia.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest - -from ..wikipedia import WikipediaPlugin - - -class TestWikipediaPlugin(unittest.TestCase): - def test_limit_text_length(self): - text = "lorem ipsum blah blah." - result = WikipediaPlugin.limit_text_length(text, max_length=10) - self.assertEqual(result, "lorem…") - result = WikipediaPlugin.limit_text_length(text, max_length=15) - self.assertEqual(result, "lorem ipsum…") - result = WikipediaPlugin.limit_text_length(text, max_length=30) - self.assertEqual(result, "lorem ipsum blah blah.") diff --git a/edmond/plugins/wikipedia.py b/edmond/plugins/wikipedia.py index 8fb9911..75ed3da 100644 --- a/edmond/plugins/wikipedia.py +++ b/edmond/plugins/wikipedia.py @@ -1,4 +1,5 @@ import time + from typing import cast import wikipedia