Commit 8a2d08bb by Jay Zoldak

Refactor choosing the browser for lettuce tests to settings.py

parent 584bb862
...@@ -36,3 +36,4 @@ DATABASES = { ...@@ -36,3 +36,4 @@ DATABASES = {
INSTALLED_APPS += ('lettuce.django',) INSTALLED_APPS += ('lettuce.django',)
LETTUCE_APPS = ('contentstore',) LETTUCE_APPS = ('contentstore',)
LETTUCE_SERVER_PORT = 8001 LETTUCE_SERVER_PORT = 8001
LETTUCE_BROWSER = 'chrome'
from lettuce import before, after, world from lettuce import before, after, world
from splinter.browser import Browser from splinter.browser import Browser
from logging import getLogger from logging import getLogger
from django.core.management import call_command
from django.conf import settings
# Let the LMS and CMS do their one-time setup # Let the LMS and CMS do their one-time setup
# For example, setting up mongo caches # For example, setting up mongo caches
...@@ -10,18 +12,14 @@ from cms import one_time_startup ...@@ -10,18 +12,14 @@ from cms import one_time_startup
logger = getLogger(__name__) logger = getLogger(__name__)
logger.info("Loading the lettuce acceptance testing terrain file...") logger.info("Loading the lettuce acceptance testing terrain file...")
from django.core.management import call_command
@before.harvest @before.harvest
def initial_setup(server): def initial_setup(server):
''' '''
Launch the browser once before executing the tests Launch the browser once before executing the tests
''' '''
# Launch the browser app (choose one of these below) browser_driver = getattr(settings, 'LETTUCE_BROWSER', 'chrome')
world.browser = Browser('chrome') world.browser = Browser(browser_driver)
# world.browser = Browser('phantomjs')
# world.browser = Browser('firefox')
@before.each_scenario @before.each_scenario
...@@ -34,6 +32,15 @@ def reset_data(scenario): ...@@ -34,6 +32,15 @@ def reset_data(scenario):
call_command('flush', interactive=False) call_command('flush', interactive=False)
@after.each_scenario
def screenshot_on_error(scenario):
'''
Save a screenshot to help with debugging
'''
if scenario.failed:
world.browser.driver.save_screenshot('/tmp/last_failed_scenario.png')
@after.all @after.all
def teardown_browser(total): def teardown_browser(total):
''' '''
......
...@@ -67,3 +67,4 @@ MITX_FEATURES['STUB_VIDEO_FOR_TESTING'] = True ...@@ -67,3 +67,4 @@ MITX_FEATURES['STUB_VIDEO_FOR_TESTING'] = True
# Include the lettuce app for acceptance testing, including the 'harvest' django-admin command # Include the lettuce app for acceptance testing, including the 'harvest' django-admin command
INSTALLED_APPS += ('lettuce.django',) INSTALLED_APPS += ('lettuce.django',)
LETTUCE_APPS = ('courseware',) LETTUCE_APPS = ('courseware',)
LETTUCE_BROWSER = 'chrome'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment