mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-25 17:32:16 +00:00
Use chrome natively on Travis, hopefully faster
This commit is contained in:
17
.travis.yml
17
.travis.yml
@@ -7,12 +7,21 @@ python:
|
|||||||
cache: pip
|
cache: pip
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
sauce_connect:
|
apt:
|
||||||
username: davidtaylorhq
|
sources:
|
||||||
access_key:
|
- google-chrome
|
||||||
secure: "ibpjQ19LfjwfQruiJmX0j6NzyNwsS3PvRFdfXUYcfCEa9Eh20QQ/S8pOdFhRh70KIEuwN5oGuPqDkJPPTjkdY3/NCjuA7/NMTp14jAIX4XjpeNcsPFupp31vEy7KBuX4iAGpenrHJssFCwurpvrlWfwSOrk7bVZKaGUowVOXmyth1FSNQvr5c3YnlxmGvNzNBMMBDcJ3ixSlS9pBRLnHIJ1w3/f9Lx2uONkVMeGM6rVyuHholWvanIyNVYtO9JkXkoie6n1R3gNbXCyJdxSRn2OLppdryUaA0wUPJSu3hqEM3R5EsRDiFJszkJLTwSBG8x4k/dbqim7stjsu1qpUhCIG5mT6e+UI9auPi/5nlwlVmPhSq58qBP53vH3hs++02wjDlgvTGB1p4PqFblHhVaslaQ166bo9skGMZb0fXLlM1aCmmwFTpC5ofiPTSRTdJcljHG/d3JabKX03ME+nX2LFPIMnSLXgrjrfh2ppI6LFESiX3Z8jYUdsgTFeN3nQZ8U0kyb5X9Ay9YFnAaYD9OuxaqweTmqAJQj093GK38+79WMN2jnvEUzM1ZjI8Y4L/f3rHvhNIwYvZjQ+gJRhUqJh2Qruk7ke7uQ1oecxIqRHj8hIFEkuBcM3e86MkRiYQXXI9jOX3JrhI/jivAjFuw0flU2tjLNgM7tUYzjMyqk="
|
packages:
|
||||||
|
- google-chrome-stable
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- "export DISPLAY=:99.0"
|
||||||
|
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- wget http://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip
|
||||||
|
- unzip chromedriver_linux64.zip
|
||||||
|
- export PATH=$PATH:$(pwd)
|
||||||
|
- chmod +x chromedriver
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- pip install coveralls codeclimate-test-reporter
|
- pip install coveralls codeclimate-test-reporter
|
||||||
|
|
||||||
|
|||||||
@@ -26,50 +26,14 @@ from django.conf import settings
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
browsers = [{"platform": "macOS 10.12",
|
def create_browser():
|
||||||
"browserName": "chrome",
|
driver = webdriver.Chrome()
|
||||||
"version": "latest"},
|
driver.maximize_window()
|
||||||
]
|
return driver
|
||||||
|
|
||||||
|
|
||||||
def on_platforms(platforms):
|
|
||||||
if not os.environ.get("TRAVIS"):
|
|
||||||
platforms = {'local'}
|
|
||||||
|
|
||||||
def decorator(base_class):
|
|
||||||
module = sys.modules[base_class.__module__].__dict__
|
|
||||||
for i, platform in enumerate(platforms):
|
|
||||||
d = dict(base_class.__dict__)
|
|
||||||
d['desired_capabilities'] = platform
|
|
||||||
name = "%s_%s" % (base_class.__name__, i + 1)
|
|
||||||
module[name] = type(name, (base_class,), d)
|
|
||||||
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_browser(test_name, desired_capabilities):
|
|
||||||
# return webdriver.Chrome()
|
|
||||||
if os.environ.get("TRAVIS"):
|
|
||||||
username = os.environ["SAUCE_USERNAME"]
|
|
||||||
access_key = os.environ["SAUCE_ACCESS_KEY"]
|
|
||||||
caps = {'browserName': desired_capabilities['browserName']}
|
|
||||||
caps['platform'] = desired_capabilities['platform']
|
|
||||||
caps['version'] = desired_capabilities['version']
|
|
||||||
caps["tunnel-identifier"] = os.environ["TRAVIS_JOB_NUMBER"]
|
|
||||||
caps["name"] = '#' + os.environ["TRAVIS_JOB_NUMBER"] + ": " + test_name
|
|
||||||
hub_url = "%s:%s@localhost:4445" % (username, access_key)
|
|
||||||
driver = webdriver.Remote(desired_capabilities=caps, command_executor="http://%s/wd/hub" % hub_url)
|
|
||||||
return driver
|
|
||||||
else:
|
|
||||||
return webdriver.Chrome()
|
|
||||||
|
|
||||||
|
|
||||||
@on_platforms(browsers)
|
|
||||||
class UserRegistrationTest(LiveServerTestCase):
|
class UserRegistrationTest(LiveServerTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.browser = create_browser(self.id(), self.desired_capabilities)
|
self.browser = create_browser()
|
||||||
|
|
||||||
self.browser.implicitly_wait(3) # Set implicit wait session wide
|
self.browser.implicitly_wait(3) # Set implicit wait session wide
|
||||||
os.environ['RECAPTCHA_TESTING'] = 'True'
|
os.environ['RECAPTCHA_TESTING'] = 'True'
|
||||||
@@ -198,7 +162,6 @@ class UserRegistrationTest(LiveServerTestCase):
|
|||||||
|
|
||||||
# All is well
|
# All is well
|
||||||
|
|
||||||
@on_platforms(browsers)
|
|
||||||
class EventTest(LiveServerTestCase):
|
class EventTest(LiveServerTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.profile = models.Profile(
|
self.profile = models.Profile(
|
||||||
@@ -209,7 +172,7 @@ class EventTest(LiveServerTestCase):
|
|||||||
|
|
||||||
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05',rate=0.20,comment='test1')
|
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05',rate=0.20,comment='test1')
|
||||||
|
|
||||||
self.browser = create_browser(self.id(), self.desired_capabilities)
|
self.browser = create_browser()
|
||||||
self.browser.implicitly_wait(10) # Set implicit wait session wide
|
self.browser.implicitly_wait(10) # Set implicit wait session wide
|
||||||
# self.browser.maximize_window()
|
# self.browser.maximize_window()
|
||||||
|
|
||||||
@@ -622,6 +585,7 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.browser.execute_script("document.getElementById('id_end_date').value='3015-04-23'")
|
self.browser.execute_script("document.getElementById('id_end_date').value='3015-04-23'")
|
||||||
|
|
||||||
# Attempt to save - should fail
|
# Attempt to save - should fail
|
||||||
|
wait.until(animation_is_finished())
|
||||||
save.click()
|
save.click()
|
||||||
|
|
||||||
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
||||||
@@ -726,6 +690,7 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.browser.execute_script("document.getElementById('id_start_date').value='3015-04-24'")
|
self.browser.execute_script("document.getElementById('id_start_date').value='3015-04-24'")
|
||||||
|
|
||||||
# Save the rig
|
# Save the rig
|
||||||
|
wait.until(animation_is_finished())
|
||||||
save.click()
|
save.click()
|
||||||
detail_panel = self.browser.find_element_by_xpath("//div[@id='content']/div/div[6]/div/div")
|
detail_panel = self.browser.find_element_by_xpath("//div[@id='content']/div/div[6]/div/div")
|
||||||
self.assertTrue(detail_panel.is_displayed())
|
self.assertTrue(detail_panel.is_displayed())
|
||||||
@@ -841,7 +806,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
tz = pytz.timezone(settings.TIME_ZONE)
|
tz = pytz.timezone(settings.TIME_ZONE)
|
||||||
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)
|
return tz.localize(datetime(year, month, day, hour, min)).astimezone(pytz.utc)
|
||||||
|
|
||||||
@on_platforms(browsers)
|
|
||||||
class IcalTest(LiveServerTestCase):
|
class IcalTest(LiveServerTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.all_events = set(range(1, 18))
|
self.all_events = set(range(1, 18))
|
||||||
@@ -904,7 +868,7 @@ class IcalTest(LiveServerTestCase):
|
|||||||
description="non rig today cancelled")
|
description="non rig today cancelled")
|
||||||
|
|
||||||
|
|
||||||
self.browser = create_browser(self.id(), self.desired_capabilities)
|
self.browser = create_browser()
|
||||||
self.browser.implicitly_wait(3) # Set implicit wait session wide
|
self.browser.implicitly_wait(3) # Set implicit wait session wide
|
||||||
os.environ['RECAPTCHA_TESTING'] = 'True'
|
os.environ['RECAPTCHA_TESTING'] = 'True'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user