aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin2013-11-16 20:32:46 +0100
committerAymeric Augustin2013-11-16 20:32:46 +0100
commit13266d8c561498879f6519b8f03039d90a0a36cd (patch)
tree94241f429faeaddc20a4b3a281ff1be86f9fe1f7 /tests
parentac79628d31040a5500b4d10534ee09174523b763 (diff)
downloaddjango-debug-toolbar-13266d8c561498879f6519b8f03039d90a0a36cd.tar.bz2
Add Selenim test.
Diffstat (limited to 'tests')
-rw-r--r--tests/settings.py2
-rw-r--r--tests/test_integration.py37
2 files changed, 38 insertions, 1 deletions
diff --git a/tests/settings.py b/tests/settings.py
index 4805cee..24e0cd4 100644
--- a/tests/settings.py
+++ b/tests/settings.py
@@ -24,6 +24,8 @@ INSTALLED_APPS = [
'tests',
]
+MEDIA_URL = '/media/' # Avoids https://code.djangoproject.com/ticket/21451
+
MIDDLEWARE_CLASSES = [
'debug_toolbar.middleware.DebugToolbarMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 19cb77a..9a3fbcc 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -2,10 +2,19 @@
from __future__ import unicode_literals
+import os
from xml.etree import ElementTree as ET
-from django.test import TestCase, RequestFactory
+try:
+ from selenium import webdriver
+ from selenium.common.exceptions import NoSuchElementException
+ from selenium.webdriver.support.wait import WebDriverWait
+except ImportError:
+ webdriver = None
+
+from django.test import LiveServerTestCase, RequestFactory, TestCase
from django.test.utils import override_settings
+from django.utils.unittest import skipIf, skipUnless
from debug_toolbar.middleware import DebugToolbarMiddleware, show_toolbar
@@ -92,3 +101,29 @@ class DebugToolbarIntegrationTestCase(TestCase):
def test_xml_validation(self):
response = self.client.get('/regular/XML/')
ET.fromstring(response.content) # shouldn't raise ParseError
+
+
+@skipIf(webdriver is None, "selenium isn't installed")
+@skipUnless('DJANGO_SELENIUM_TESTS' in os.environ, "selenium tests not requested")
+@override_settings(DEBUG=True)
+class DebugToolbarLiveTestCase(LiveServerTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ super(DebugToolbarLiveTestCase, cls).setUpClass()
+ cls.selenium = webdriver.Firefox()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.selenium.quit()
+ super(DebugToolbarLiveTestCase, cls).tearDownClass()
+
+ def test_basic(self):
+ self.selenium.get(self.live_server_url + '/regular/basic/')
+ version_button = self.selenium.find_element_by_class_name('VersionDebugPanel')
+ version_panel = self.selenium.find_element_by_id('VersionDebugPanel')
+ with self.assertRaises(NoSuchElementException):
+ version_panel.find_element_by_tag_name('table')
+ version_button.click() # load contents of the version panel
+ WebDriverWait(self.selenium, timeout=10).until(
+ lambda selenium: version_panel.find_element_by_tag_name('table'))