Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove warnings for TemplateResponse #2368

Merged
merged 2 commits into from
Mar 29, 2024
Merged

test: remove warnings for TemplateResponse #2368

merged 2 commits into from
Mar 29, 2024

Conversation

dni
Copy link
Member

@dni dni commented Mar 26, 2024

removes warnings

tests/core/views/test_generic.py::test_core_views_generic
tests/core/views/test_generic.py::test_get_wallet_with_user_and_wallet
tests/core/views/test_generic.py::test_get_extensions
tests/core/views/test_public_api.py::test_core_views_generic
  /home/dni/.cache/pypoetry/virtualenvs/lnbits-XeqO4Z-j-py3.10/lib/python3.10/site-packages/starlette/templating.py:178: DeprecationWarning: The `name` is not the first para
meter anymore. The first parameter should be the `Request` instance.
  Replace `TemplateResponse(name, {"request": request})` by `TemplateResponse(request, name)`.
    warnings.warn(

@dni dni requested review from prusnak and motorina0 March 26, 2024 21:49
lnbits/middleware.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.50%. Comparing base (9b5bb1b) to head (4eae10e).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2368   +/-   ##
=======================================
  Coverage   58.50%   58.50%           
=======================================
  Files          65       65           
  Lines        9379     9379           
=======================================
  Hits         5487     5487           
  Misses       3892     3892           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dni dni requested a review from talvasconcelos March 27, 2024 07:13
dni added 2 commits March 28, 2024 10:32
removes warnings
```
tests/core/views/test_generic.py::test_core_views_generic
tests/core/views/test_generic.py::test_get_wallet_with_user_and_wallet
tests/core/views/test_generic.py::test_get_extensions
tests/core/views/test_public_api.py::test_core_views_generic
  /home/dni/.cache/pypoetry/virtualenvs/lnbits-XeqO4Z-j-py3.10/lib/python3.10/site-packages/starlette/templating.py:178: DeprecationWarning: The `name` is not the first para
meter anymore. The first parameter should be the `Request` instance.
  Replace `TemplateResponse(name, {"request": request})` by `TemplateResponse(request, name)`.
    warnings.warn(
```
@dni dni added this to the 0.12.5 milestone Mar 29, 2024
@dni dni added testing Code testing code health Make the code more beautiful labels Mar 29, 2024
@motorina0
Copy link
Collaborator

I assume this change has to be performed on all extensions too.

Suggestion: abstract the TemplateResponse so future changes to fastapi will only be handled in one place.

From:

return template_renderer().TemplateResponse(
    request, "error.html", {"err": f"Error: {str(exc)}"}
)

To:

return template_response_renderer(
  request, "error.html", {"err": f"Error: {str(exc)}"}
)

@dni dni merged commit 4679d32 into dev Mar 29, 2024
23 checks passed
@dni dni deleted the test-warnings branch March 29, 2024 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Make the code more beautiful testing Code testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants