Skip to content

Commit

Permalink
update build matrix and python 3 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
digi604 committed Dec 13, 2013
1 parent aa89a56 commit 5f5e4e9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 30 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Expand Up @@ -83,9 +83,17 @@ matrix:
env: DJANGO=1.6 DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=1
- python: 3.3
env: DJANGO=trunk DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=1
- python: 2.7
env: DJANGO=1.4 DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=0
- python: 2.7
env: DJANGO=1.5 DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=0
- python: 2.7
env: DJANGO=1.6 DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=0
- python: 2.7
env: DJANGO=trunk DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=0
allow_failures:
- python: 3.3
env: DJANGO=trunk DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=0
env: DJANGO=trunk DATABASE_URL='sqlite://localhost/:memory:' SELENIUM=1
- python: 3.3
env: DJANGO=trunk DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' SELENIUM=0
- python: 3.3
Expand Down
57 changes: 28 additions & 29 deletions cms/tests/frontend.py
Expand Up @@ -6,7 +6,7 @@
from django.contrib.sites.models import Site
from django.utils import unittest
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoSuchElementException, NoAlertPresentException
from django.test import LiveServerTestCase
import os

Expand All @@ -32,6 +32,7 @@ def setUpClass(cls):
cls.driver.implicitly_wait(30)
else:
cls.driver = webdriver.Firefox()
cls.accept_next_alert = True
super(CMSLiveTests, cls).setUpClass()

def stop_server(self):
Expand Down Expand Up @@ -79,27 +80,45 @@ def wait_page_loaded(self):
# ignore it.
pass

def is_element_present(self, how, what):
try:
self.driver.find_element(by=how, value=what)
except NoSuchElementException:
return False
return True

def is_alert_present(self):
try:
self.driver.switch_to_alert()
except NoAlertPresentException:
return False
return True

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally:
self.accept_next_alert = True


class ToolbarBasicTests(CMSLiveTests):
def setUp(self):
Site.objects.create(domain='example.org', name='example.org')
self.base_url = self.live_server_url
self.driver.implicitly_wait(2)
self.verificationErrors = []
self.accept_next_alert = True

user = User()
user.username = 'admin'
user.set_password('admin')
user.is_superuser = user.is_staff = user.is_active = True
user.save()

super(ToolbarBasicTests, self).setUp()

def tearDown(self):
self.assertEqual([], self.verificationErrors)

#@skipIf(not WebDriver, 'Selenium not found or Django too old')
def test_toolbar_login(self):
create_page('Home', 'simple.html', 'en', published=True).publish()
url = '%s/?edit' % self.live_server_url
Expand Down Expand Up @@ -130,23 +149,3 @@ def test_basic_add_pages(self):
driver.find_element_by_id("id_title").send_keys("SubPage")
driver.find_element_by_name("_save").click()

def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True

def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException, e: return False
return True

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True

0 comments on commit 5f5e4e9

Please sign in to comment.