diff --git a/discord_rss_bot/main.py b/discord_rss_bot/main.py index 4de3c9b..7ef30da 100644 --- a/discord_rss_bot/main.py +++ b/discord_rss_bot/main.py @@ -954,7 +954,7 @@ async def search(request: Request, query: str): """ reader.update_search() context = create_search_context(query) - return templates.TemplateResponse("search.html", {"request": request, **context}) + return templates.TemplateResponse(request=request, name="search.html", context={"request": request, **context}) @app.get("/post_entry", response_class=HTMLResponse) diff --git a/tests/test_search.py b/tests/test_search.py index 7518963..2819734 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -6,14 +6,14 @@ from typing import TYPE_CHECKING from reader import Feed, Reader, make_reader -from discord_rss_bot.search import create_html_for_search_results +from discord_rss_bot.search import create_search_context if TYPE_CHECKING: from collections.abc import Iterable -def test_create_html_for_search_results() -> None: - """Test create_html_for_search_results.""" +def test_create_search_context() -> None: + """Test create_search_context.""" # Create a reader. with tempfile.TemporaryDirectory() as temp_dir: # Create the temp directory. @@ -43,10 +43,9 @@ def test_create_html_for_search_results() -> None: reader.enable_search() reader.update_search() - # Create the HTML and check if it is not empty. - search_html: str = create_html_for_search_results("a", reader) - assert search_html is not None, f"The search HTML should not be None. Got: {search_html}" - assert len(search_html) > 10, f"The search HTML should be longer than 10 characters. Got: {len(search_html)}" + # Create the search context. + context: dict = create_search_context("test", custom_reader=reader) + assert context is not None, f"The context should not be None. Got: {context}" # Close the reader, so we can delete the directory. reader.close()