Remove unneeded variable
This commit is contained in:
@ -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()
|
@lru_cache()
|
||||||
def get_reader(custom_location: str = "") -> Reader:
|
def get_reader(custom_location: str = "") -> Reader:
|
||||||
"""Get the 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)
|
return make_reader(url=db_location)
|
||||||
|
|
||||||
@ -64,7 +48,6 @@ def list_webhooks(reader: Reader) -> list[dict[str, str]]:
|
|||||||
# Get global tags
|
# Get global tags
|
||||||
if reader.get_tags(()) is not None:
|
if reader.get_tags(()) is not None:
|
||||||
for tag in reader.get_tag_keys(()):
|
for tag in reader.get_tag_keys(()):
|
||||||
# Check if the tag is named webhooks
|
|
||||||
if tag == "webhooks":
|
if tag == "webhooks":
|
||||||
webhooks = reader.get_tag((), "webhooks") # type: ignore
|
webhooks = reader.get_tag((), "webhooks") # type: ignore
|
||||||
|
|
||||||
|
@ -2,26 +2,9 @@ import os
|
|||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from platformdirs import user_data_dir
|
|
||||||
from reader import Reader
|
from reader import Reader
|
||||||
|
|
||||||
from discord_rss_bot.settings import data_dir, default_custom_message, get_db_location, get_reader
|
from discord_rss_bot.settings import data_dir, default_custom_message, 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")
|
|
||||||
|
|
||||||
|
|
||||||
def test_reader() -> None:
|
def test_reader() -> None:
|
||||||
|
Reference in New Issue
Block a user