Commit 782cb054 by Peter Fogg

Add passing Lettuce testing for video autoplay in LMS.

parent 1ead8577
...@@ -5,8 +5,6 @@ from lettuce import world, step ...@@ -5,8 +5,6 @@ from lettuce import world, step
from nose.tools import assert_true from nose.tools import assert_true
from nose.tools import assert_equal from nose.tools import assert_equal
from xmodule.modulestore.django import _MODULESTORES, modulestore
from xmodule.templates import update_templates
from auth.authz import get_user_by_email from auth.authz import get_user_by_email
from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys
...@@ -50,31 +48,31 @@ def i_press_the_category_delete_icon(step, category): ...@@ -50,31 +48,31 @@ def i_press_the_category_delete_icon(step, category):
@step('I have opened a new course in Studio$') @step('I have opened a new course in Studio$')
def i_have_opened_a_new_course(step): def i_have_opened_a_new_course(step):
open_new_course()
####### HELPER FUNCTIONS ##############
def open_new_course():
world.clear_courses() world.clear_courses()
log_into_studio() log_into_studio()
create_a_course() create_a_course()
####### HELPER FUNCTIONS ##############
def create_studio_user( def create_studio_user(
uname='robot', uname='robot',
email='robot+studio@edx.org', email='robot+studio@edx.org',
password='test', password='test',
is_staff=False): is_staff=False):
studio_user = world.UserFactory.build( studio_user = world.UserFactory(
username=uname, username=uname,
email=email, email=email,
password=password, password=password,
is_staff=is_staff) is_staff=is_staff)
studio_user.set_password(password)
studio_user.save()
registration = world.RegistrationFactory(user=studio_user) registration = world.RegistrationFactory(user=studio_user)
registration.register(studio_user) registration.register(studio_user)
registration.activate() registration.activate()
user_profile = world.UserProfileFactory(user=studio_user)
def fill_in_course_info( def fill_in_course_info(
name='Robot Super Course', name='Robot Super Course',
...@@ -153,7 +151,7 @@ def set_date_and_time(date_css, desired_date, time_css, desired_time): ...@@ -153,7 +151,7 @@ def set_date_and_time(date_css, desired_date, time_css, desired_time):
world.css_fill(time_css, desired_time) world.css_fill(time_css, desired_time)
e = world.css_find(time_css).first e = world.css_find(time_css).first
e._element.send_keys(Keys.TAB) e._element.send_keys(Keys.TAB)
time.sleep(float(1)) time.sleep(float(1))
@step('I have created a Video component$') @step('I have created a Video component$')
......
# disable missing docstring
#pylint: disable=C0111 #pylint: disable=C0111
#pylint: disable=W0621
from lettuce import world from lettuce import world
from nose.tools import assert_equal from nose.tools import assert_equal
from terrain.steps import reload_the_page
import time
@world.absorb @world.absorb
...@@ -24,9 +23,7 @@ def click_new_component_button(step, component_button_css): ...@@ -24,9 +23,7 @@ def click_new_component_button(step, component_button_css):
@world.absorb @world.absorb
def click_component_from_menu(instance_id, expected_css): def click_component_from_menu(instance_id, expected_css):
new_instance = world.browser.find_by_id(instance_id) elem_css = "a[data-location='%s']" % instance_id
assert_equal(1, len(new_instance)) assert_equal(1, len(world.css_find(elem_css)))
# TODO: why is this sleep necessary? world.css_click(elem_css)
time.sleep(float(1))
new_instance[0].click()
assert_equal(1, len(world.css_find(expected_css))) assert_equal(1, len(world.css_find(expected_css)))
...@@ -9,23 +9,26 @@ from common import * ...@@ -9,23 +9,26 @@ from common import *
@step('when I view it it does autoplay') @step('when I view it it does autoplay')
def does_autoplay(step): def does_autoplay(step):
assert world.css_find('.video')[0]['data-autoplay'] == 'True' assert(world.css_find('.video')[0]['data-autoplay'] == 'True')
assert world.css_find('.video_control')[0].has_class('pause')
@step('the course has a Video component') @step('the course has a Video component')
def view_video(step): def view_video(step):
model_course = 'model_course'
coursename = TEST_COURSE_NAME.replace(' ', '_') coursename = TEST_COURSE_NAME.replace(' ', '_')
i_am_registered_for_the_course(step, coursename) i_am_registered_for_the_course(step, coursename)
# Make sure we have a video # Make sure we have a video
video = create_video_component(coursename) video = add_video_to_course(coursename)
url = django_url('/courses/edx/%s/Test_Course/courseware/' % model_course) chapter_name = TEST_SECTION_NAME.replace(" ", "_")
section_name = chapter_name
url = django_url('/courses/edx/Test_Course/Test_Course/courseware/%s/%s' %
(chapter_name, section_name))
world.browser.visit(url) world.browser.visit(url)
print('\n\n\n')
print world.browser.html
print('\n\n\n')
def create_video_component(course): def add_video_to_course(course):
return world.ItemFactory.create(parent_location=section_location(course), template_name = 'i4x://edx/templates/video/default'
template='i4x://edx/templates/video/default') world.ItemFactory.create(parent_location=section_location(course),
template=template_name,
display_name='Video')
...@@ -3,8 +3,24 @@ ...@@ -3,8 +3,24 @@
% endif % endif
%if settings.MITX_FEATURES['STUB_VIDEO_FOR_TESTING']: %if settings.MITX_FEATURES['STUB_VIDEO_FOR_TESTING']:
<div id="stub_out_video_for_testing"></div> <div id="stub_out_video_for_testing">
<div class="video" data-autoplay="${settings.MITX_FEATURES['AUTOPLAY_VIDEOS']}">
<section class="video-controls">
<div class="slider"></div>
<div>
<ul class="vcr">
<li><a class="video_control" href="#"></a></li>
<li>
<div class="vidtime">0:00 / 0:00</div>
</li>
</ul>
<div class="secondary-controls">
<a href="#" class="add-fullscreen" title="Fill browser">Fill Browser</a>
</div>
</div>
</section>
</div>
</div>
%elif settings.MITX_FEATURES.get('USE_YOUTUBE_OBJECT_API') and normal_speed_video_id: %elif settings.MITX_FEATURES.get('USE_YOUTUBE_OBJECT_API') and normal_speed_video_id:
<object width="640" height="390"> <object width="640" height="390">
<param name="movie" <param name="movie"
......
...@@ -3,7 +3,22 @@ ...@@ -3,7 +3,22 @@
% endif % endif
%if settings.MITX_FEATURES['STUB_VIDEO_FOR_TESTING']: %if settings.MITX_FEATURES['STUB_VIDEO_FOR_TESTING']:
<div id="stub_out_video_for_testing"></div> <div id="stub_out_video_for_testing">
<div class="video" data-autoplay="${settings.MITX_FEATURES['AUTOPLAY_VIDEOS']}">
<div class="slider"></div>
<div>
<ul class="vcr">
<li><a class="video_control" href="#"></a></li>
<li>
<div class="vidtime">0:00 / 0:00</div>
</li>
</ul>
<div class="secondary-controls">
<a href="#" class="add-fullscreen" title="Fill browser">Fill Browser</a>
</div>
</div>
</div>
</div>
%else: %else:
<div <div
id="video_${id}" id="video_${id}"
......
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