Skip to content

Commit bdf7248

Browse files
committed
fix: is_active_endpoint print
Remove print statement from is_active_endpoint and fix function coverage
1 parent 54c5e4a commit bdf7248

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/bootlace/util.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,17 @@ def converter(value: str | T) -> T:
277277
def is_active_endpoint(endpoint: str, url_kwargs: Mapping[str, Any], ignore_query: bool = True) -> bool:
278278
"""Check if the current request is for the given endpoint and URL kwargs"""
279279
if request.endpoint != endpoint:
280-
print(f"endpoint: {request.endpoint} != {endpoint}")
281280
return False
282281

283282
if request.url_rule is None: # pragma: no cover
284283
return False
285284

286285
try:
287286
rule_url = request.url_rule.build(url_kwargs, append_unknown=not ignore_query)
288-
except TypeError:
289-
# URL rule does not support the given URL kwargs
287+
except TypeError: # pragma: no cover
290288
return False
291289

292-
if rule_url is None: # pragma: no cover
290+
if rule_url is None:
293291
return False
294292

295293
_, url = rule_url

tests/test_util.py

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from dominate import tags
55
from flask import Blueprint
66
from flask import Flask
7+
from flask import request
78

89
from bootlace.util import as_tag
910
from bootlace.util import is_active_blueprint
@@ -161,6 +162,15 @@ def test_is_active_endpoint(app: Flask, uri: str, endpoint: str, kwargs: dict[st
161162
assert is_active_endpoint(endpoint, kwargs) is expected
162163

163164

165+
@pytest.mark.usefixtures("bp")
166+
def test_is_active_endpoint_invalid_kwargs(app: Flask) -> None:
167+
168+
with app.test_request_context("/"):
169+
assert request.endpoint == "home"
170+
assert request.url_rule is not None
171+
assert not is_active_endpoint("home", {"id": "a"}, ignore_query=False)
172+
173+
164174
@pytest.mark.usefixtures("bp")
165175
@pytest.mark.parametrize(
166176
"uri,blueprint,expected",

0 commit comments

Comments
 (0)