-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Load the content of panels dynamically #447
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
Merged
aaugustin
merged 9 commits into
django-commons:master
from
aaugustin:load-panels-contents-on-demand
Nov 10, 2013
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
631bbd1
Avoid some implicit global lookups.
aaugustin 2816c6f
Load the content of panels dynamically.
aaugustin 53bf40f
Improve regression test added in 8525bfc7.
aaugustin b8d3c1c
Invalidate cached list of panels during tests.
aaugustin a29bbc7
Move a test specific to the profiling panel in its module.
aaugustin c4e833a
Move a test specific to the template panel in its module.
aaugustin b1d8b11
Normalize the way we write panel tests.
aaugustin ad31833
Move two tests specific to the request vars panel in their module.
aaugustin b61c85f
Fix PEP 8 violations.
aaugustin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,29 @@ | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.contrib.auth.models import User | ||
| from django.db import IntegrityError, transaction | ||
| from django.test import TestCase | ||
| from django.test.utils import override_settings | ||
|
|
||
|
|
||
| @override_settings(DEBUG=True, | ||
| DEBUG_TOOLBAR_PANELS=['debug_toolbar.panels.profiling.ProfilingDebugPanel']) | ||
| class ProfilingPanelIntegrationTestCase(TestCase): | ||
|
|
||
| urls = 'tests.urls' | ||
|
|
||
| def test_view_executed_once(self): | ||
|
|
||
| self.assertEqual(User.objects.count(), 0) | ||
|
|
||
| response = self.client.get('/new_user/') | ||
| self.assertContains(response, 'Profiling') | ||
| self.assertEqual(User.objects.count(), 1) | ||
|
|
||
| with self.assertRaises(IntegrityError): | ||
| if hasattr(transaction, 'atomic'): # Django >= 1.6 | ||
| with transaction.atomic(): | ||
| response = self.client.get('/new_user/') | ||
| else: | ||
| response = self.client.get('/new_user/') | ||
| self.assertEqual(User.objects.count(), 1) |
This file contains hidden or 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,35 @@ | ||
| # coding: utf-8 | ||
|
|
||
| from __future__ import unicode_literals | ||
|
|
||
| from django.utils import six | ||
|
|
||
| from debug_toolbar.panels.request_vars import RequestVarsDebugPanel | ||
|
|
||
| from ..base import BaseTestCase | ||
|
|
||
|
|
||
| class RequestVarsDebugPanelTestCase(BaseTestCase): | ||
|
|
||
| def setUp(self): | ||
| super(RequestVarsDebugPanelTestCase, self).setUp() | ||
| self.panel = self.toolbar.get_panel(RequestVarsDebugPanel) | ||
|
|
||
| def test_non_ascii_session(self): | ||
| self.request.session = {'où': 'où'} | ||
| if not six.PY3: | ||
| self.request.session['là'.encode('utf-8')] = 'là'.encode('utf-8') | ||
| self.panel.process_request(self.request) | ||
| self.panel.process_response(self.request, self.response) | ||
| content = self.panel.content() | ||
| if six.PY3: | ||
| self.assertIn('où', content) | ||
| else: | ||
| self.assertIn('o\\xf9', content) | ||
| self.assertIn('l\\xc3\\xa0', content) | ||
|
|
||
| def test_object_with_non_ascii_repr_in_request_vars(self): | ||
| self.request.path = '/non_ascii_request/' | ||
| self.panel.process_request(self.request) | ||
| self.panel.process_response(self.request, self.response) | ||
| self.assertIn('nôt åscíì', self.panel.content()) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No opinion really but what about
collections.deque(maxlen=10)? Then as you add more they automatically fall off the other end. You don't really have to keep count.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I first tried using a
deque, but I need a dict-like behavior to look up items inget_saved_toolbar.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see it now. Thanks.