From 587d86bfb282c50fbbe00f62c7008c0dc58b523e Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Tue, 30 Jul 2013 14:45:33 -0400 Subject: [PATCH] Add acceptance test for XML-only video content. Since we've had issues with the default video being incorrectly shown, this creates an XML-only video and ensures that the correct (non-default) Youtube ID is sent to the client. --- .../contentstore/features/video.feature | 4 ++ cms/djangoapps/contentstore/features/video.py | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/cms/djangoapps/contentstore/features/video.feature b/cms/djangoapps/contentstore/features/video.feature index dc85bbb17f..d67a0b2f72 100644 --- a/cms/djangoapps/contentstore/features/video.feature +++ b/cms/djangoapps/contentstore/features/video.feature @@ -47,3 +47,7 @@ Feature: Video Component Given I have created a Video Alpha component And I have set "show captions" to True Then when I view the videoalpha it does show the captions + + Scenario: Video data is shown correctly + Given I have created a video with only XML data + Then the correct Youtube video is shown diff --git a/cms/djangoapps/contentstore/features/video.py b/cms/djangoapps/contentstore/features/video.py index 72a8762197..0f8b87171c 100644 --- a/cms/djangoapps/contentstore/features/video.py +++ b/cms/djangoapps/contentstore/features/video.py @@ -2,6 +2,9 @@ from lettuce import world, step from terrain.steps import reload_the_page +from xmodule.modulestore import Location +from contentstore.utils import get_modulestore + ############### ACTIONS #################### @@ -44,3 +47,39 @@ def videoalpha_name_persisted(step): reload_the_page(step) world.edit_component() world.verify_setting_entry(world.get_setting_entry('Display Name'), 'Display Name', '3.4', True) + + +@step('I have created a video with only XML data') +def xml_only_video(step): + # Create a new video *without* metadata. This requires a certain + # amount of rummaging to make sure all the correct data is present + step.given('I have clicked the new unit button') + + # Wait for the new unit to be created and to load the page + world.wait(1) + + location = world.scenario_dict['COURSE'].location + store = get_modulestore(location) + + parent_location = store.get_items(Location(category='vertical', revision='draft'))[0].location + + youtube_id = 'ABCDEFG' + world.scenario_dict['YOUTUBE_ID'] = youtube_id + + # Create a new Video component, but ensure that it doesn't have + # metadata. This allows us to test that we are correctly parsing + # out XML + video = world.ItemFactory.create( + parent_location=parent_location, + category='video', + data='' % youtube_id + ) + + # Refresh to see the new video + reload_the_page(step) + + +@step('The correct Youtube video is shown') +def the_youtube_video_is_shown(_step): + ele = world.css_find('.video').first + assert ele['data-youtube-id-1-0'] == world.scenario_dict['YOUTUBE_ID']