fix: update test assertions and lint fixes for Starlette 1.0 TemplateResponse API
Update test mocks to check kwargs["context"] instead of positional args[1] for tests that verify auth.py and base.py wrapper behavior. Fix B026 lint error by avoiding star-arg after keyword argument. Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/7b5f7e0d-89ad-43be-b68d-a9c0c5407a7e
This commit is contained in:
+3
-3
@@ -430,8 +430,8 @@ class TestLoginFunction:
|
||||
# Verify TemplateResponse was called with correct context
|
||||
mock_templates.TemplateResponse.assert_called_once()
|
||||
call_args = mock_templates.TemplateResponse.call_args
|
||||
assert call_args[0][0] == "login.html"
|
||||
context = call_args[0][1]
|
||||
assert call_args[0][1] == "login.html"
|
||||
context = call_args.kwargs["context"]
|
||||
assert context["error"] == "Test error"
|
||||
assert context["message"] == "Test message"
|
||||
|
||||
@@ -450,7 +450,7 @@ class TestLoginFunction:
|
||||
|
||||
mock_templates.TemplateResponse.assert_called_once()
|
||||
call_args = mock_templates.TemplateResponse.call_args
|
||||
context = call_args[0][1]
|
||||
context = call_args.kwargs["context"]
|
||||
assert context["error"] is None
|
||||
assert context["message"] is None
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ class TestLoginEndpoint:
|
||||
# Verify template was rendered with OAuth enabled
|
||||
mock_templates.TemplateResponse.assert_called_once()
|
||||
call_args = mock_templates.TemplateResponse.call_args
|
||||
context = call_args[0][1]
|
||||
context = call_args.kwargs["context"]
|
||||
assert context["show_oauth"] is True
|
||||
assert context["oauth_provider_name"] == "Test SSO"
|
||||
|
||||
|
||||
@@ -69,8 +69,9 @@ class TestViewsBase:
|
||||
context = {"request": req}
|
||||
template_response_with_version("template.html", context)
|
||||
|
||||
args, _ = mock_orig.call_args
|
||||
assert args[1].get("csrf_token") == "my-csrf"
|
||||
args, kwargs = mock_orig.call_args
|
||||
context = kwargs.get("context", {})
|
||||
assert context.get("csrf_token") == "my-csrf"
|
||||
|
||||
def test_kwargs_context_no_request(self):
|
||||
"""Test kwargs context path when request is not in context."""
|
||||
|
||||
@@ -345,7 +345,7 @@ class TestLoginPageSocialProviders:
|
||||
|
||||
mock_templates.TemplateResponse.assert_called_once()
|
||||
call_args = mock_templates.TemplateResponse.call_args
|
||||
context = call_args.kwargs.get("context") or call_args[0][2] if len(call_args[0]) > 2 else {}
|
||||
context = call_args.kwargs.get("context", {})
|
||||
assert context["social_providers"] == mock_providers
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -371,7 +371,7 @@ class TestLoginPageSocialProviders:
|
||||
|
||||
mock_templates.TemplateResponse.assert_called_once()
|
||||
call_args = mock_templates.TemplateResponse.call_args
|
||||
context = call_args.kwargs.get("context") or call_args[0][2] if len(call_args[0]) > 2 else {}
|
||||
context = call_args.kwargs.get("context", {})
|
||||
assert context["social_providers"] == {}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user