Skip to content

Commit

Permalink
#105 log that htmx target was None instead of raising a ValueError be…
Browse files Browse the repository at this point in the history
…cause on theme change it is and that's ok + test modification
  • Loading branch information
ephes committed Sep 2, 2023
1 parent 40920b0 commit a74e039
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cast/models/index_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_template(self, request: HtmxHttpRequest, *args, **kwargs) -> str:
if request.htmx.target is not None:
template_name = target_to_template_name[request.htmx.target]
else:
raise ValueError("HTMX target is None")
logger.warning("HTMX target is None")
template = f"cast/{template_base_dir}/{template_name}"
return template

Expand Down
7 changes: 3 additions & 4 deletions tests/blog_index_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ def test_session_template_base_dir_overwrites_blog_setting(self, simple_request)
template = blog.get_template(simple_request)
assert chosen_base_dir in template

def test_blog_use_partial_template_for_htmx_request_without_target(self, htmx_request_without_target):
blog = Blog()
with pytest.raises(ValueError, match="HTMX target is None"):
blog.get_template(htmx_request_without_target)
def test_blog_use_partial_template_for_htmx_request_without_target(self, caplog, htmx_request_without_target):
Blog().get_template(htmx_request_without_target)
assert "HTMX target is None" in caplog.text

def test_blog_use_partial_template_for_htmx_request(self, htmx_request):
blog = Blog()
Expand Down

0 comments on commit a74e039

Please sign in to comment.