From 596238420a35fdd41953cbe96ce4efa41e4a9468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Sat, 28 Jan 2023 21:22:45 +0100 Subject: [PATCH] Remove unneeded variable --- discord_rss_bot/settings.py | 19 +------------------ tests/test_settings.py | 19 +------------------ 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/discord_rss_bot/settings.py b/discord_rss_bot/settings.py index e00761b..78d588e 100644 --- a/discord_rss_bot/settings.py +++ b/discord_rss_bot/settings.py @@ -19,22 +19,6 @@ default_custom_embed: dict[str, str] = { } -@lru_cache() -def get_db_location(custom_location: str = "") -> str: - """Where we store the database file. - - Args: - custom_location: Where the database file should be stored. This should be with the file name. - - Returns: - The database location. - """ - # Use the custom location if it is provided. - db_loc: str = custom_location or os.path.join(data_dir, "db.sqlite") - - return db_loc - - @lru_cache() def get_reader(custom_location: str = "") -> Reader: """Get the reader. @@ -44,7 +28,7 @@ def get_reader(custom_location: str = "") -> Reader: """ - db_location: str = get_db_location(custom_location) + db_location: str = custom_location or os.path.join(data_dir, "db.sqlite") return make_reader(url=db_location) @@ -64,7 +48,6 @@ def list_webhooks(reader: Reader) -> list[dict[str, str]]: # Get global tags if reader.get_tags(()) is not None: for tag in reader.get_tag_keys(()): - # Check if the tag is named webhooks if tag == "webhooks": webhooks = reader.get_tag((), "webhooks") # type: ignore diff --git a/tests/test_settings.py b/tests/test_settings.py index a00c4fe..2786b22 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -2,26 +2,9 @@ import os import pathlib import tempfile -from platformdirs import user_data_dir from reader import Reader -from discord_rss_bot.settings import data_dir, default_custom_message, get_db_location, get_reader - - -def test_get_db_location() -> None: - """Test getting the database location.""" - with tempfile.TemporaryDirectory() as temp_dir: - custom_loc: str = os.path.join(temp_dir, "test_db.sqlite") - - # File should not exist yet. - assert not os.path.exists(custom_loc) - - # Create the file and check if it exists. - assert get_db_location(custom_location=custom_loc) == os.path.join(temp_dir, "test_db.sqlite") - - # Test with the default location - loc: str = user_data_dir(appname="discord_rss_bot", appauthor="TheLovinator", roaming=True) - assert get_db_location() == os.path.join(loc, "db.sqlite") +from discord_rss_bot.settings import data_dir, default_custom_message, get_reader def test_reader() -> None: