diff options
| author | Aymeric Augustin | 2013-11-09 19:50:08 +0100 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-11-10 10:39:42 +0100 | 
| commit | a29bbc7cfcef52af29960f2a2f3d53e9c0b0015d (patch) | |
| tree | 2fd83359dc2a09415ba2a8c8503d3b3b59e514f0 /tests/panels/test_profiling.py | |
| parent | b8d3c1c9043c782f15e9cea9c5d4f50ca5bae46a (diff) | |
| download | django-debug-toolbar-a29bbc7cfcef52af29960f2a2f3d53e9c0b0015d.tar.bz2 | |
Move a test specific to the profiling panel in its module.
Diffstat (limited to 'tests/panels/test_profiling.py')
| -rw-r--r-- | tests/panels/test_profiling.py | 29 | 
1 files changed, 29 insertions, 0 deletions
| diff --git a/tests/panels/test_profiling.py b/tests/panels/test_profiling.py new file mode 100644 index 0000000..6a7823e --- /dev/null +++ b/tests/panels/test_profiling.py @@ -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) | 
