-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create decorator to use TOOLBAR_LANGUAGE in toolbar specific views.
This reviews the third-party panel documentation to reference these two decorators and explain them. They aren't necessary but should be used.
- Loading branch information
1 parent
b41da3c
commit d38ff8f
Showing
9 changed files
with
73 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from unittest.mock import patch | ||
|
||
from django.http import HttpResponse | ||
from django.test import RequestFactory, TestCase | ||
from django.test.utils import override_settings | ||
|
||
from debug_toolbar.decorators import render_with_toolbar_language | ||
|
||
|
||
@render_with_toolbar_language | ||
def stub_view(request): | ||
return HttpResponse(200) | ||
|
||
|
||
@override_settings(DEBUG=True, LANGUAGE_CODE="fr") | ||
class RenderWithToolbarLanguageTestCase(TestCase): | ||
@override_settings(DEBUG_TOOLBAR_CONFIG={"TOOLBAR_LANGUAGE": "de"}) | ||
@patch("debug_toolbar.decorators.language_override") | ||
def test_uses_toolbar_language(self, mock_language_override): | ||
stub_view(RequestFactory().get("/")) | ||
mock_language_override.assert_called_once_with("de") | ||
|
||
@patch("debug_toolbar.decorators.language_override") | ||
def test_defaults_to_django_language_code(self, mock_language_override): | ||
stub_view(RequestFactory().get("/")) | ||
mock_language_override.assert_called_once_with("fr") |