fix: adapt TemplateResponse calls to Starlette 1.0 new-style API
Starlette 1.0.0 changed TemplateResponse signature from (name, context_dict) to (request, name, context=dict). - Update base.py wrapper to convert old-style calls to new-style - Update main.py error handler TemplateResponse calls - Update local_auth.py, billing.py, auth.py, share.py calls - Update test mocks for new calling convention 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:
@@ -55,8 +55,8 @@ class TestDarkModeTemplateInjection:
|
||||
|
||||
captured = {}
|
||||
|
||||
def fake_original(name, ctx, **kw):
|
||||
captured.update(ctx)
|
||||
def fake_original(request_obj, name, context=None, **kw):
|
||||
captured.update(context or {})
|
||||
|
||||
with patch("app.views.base.original_template_response", side_effect=fake_original):
|
||||
mock_request = MagicMock()
|
||||
@@ -73,8 +73,8 @@ class TestDarkModeTemplateInjection:
|
||||
|
||||
captured = {}
|
||||
|
||||
def fake_original(name, ctx, **kw):
|
||||
captured.update(ctx)
|
||||
def fake_original(request_obj, name, context=None, **kw):
|
||||
captured.update(context or {})
|
||||
|
||||
with patch("app.views.base.original_template_response", side_effect=fake_original):
|
||||
mock_request = MagicMock()
|
||||
|
||||
@@ -345,7 +345,7 @@ class TestLoginPageSocialProviders:
|
||||
|
||||
mock_templates.TemplateResponse.assert_called_once()
|
||||
call_args = mock_templates.TemplateResponse.call_args
|
||||
context = call_args[0][1]
|
||||
context = call_args.kwargs.get("context") or call_args[0][2] if len(call_args[0]) > 2 else {}
|
||||
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[0][1]
|
||||
context = call_args.kwargs.get("context") or call_args[0][2] if len(call_args[0]) > 2 else {}
|
||||
assert context["social_providers"] == {}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user