From 9199f1d08bd94145f8b1c1a79dee24fc78ffa924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s=20Rocha?= Date: Wed, 14 Aug 2013 17:37:10 -0400 Subject: [PATCH] Add test for invalid YouTube IDs strings --- .../lib/xmodule/xmodule/tests/test_video.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/common/lib/xmodule/xmodule/tests/test_video.py b/common/lib/xmodule/xmodule/tests/test_video.py index 4a13d565cc..1ea4b4e187 100644 --- a/common/lib/xmodule/xmodule/tests/test_video.py +++ b/common/lib/xmodule/xmodule/tests/test_video.py @@ -64,6 +64,32 @@ class VideoModuleTest(LogicTest): '1.25': '', '1.50': ''}) + def test_parse_youtube_invalid(self): + """Ensure that ids that are invalid return an empty dict""" + + # invalid id + youtube_str = 'thisisaninvalidid' + output = VideoDescriptor._parse_youtube(youtube_str) + self.assertEqual(output, {'0.75': '', + '1.00': '', + '1.25': '', + '1.50': ''}) + # another invalid id + youtube_str = ',::,:,,' + output = VideoDescriptor._parse_youtube(youtube_str) + self.assertEqual(output, {'0.75': '', + '1.00': '', + '1.25': '', + '1.50': ''}) + + # and another one, partially invalid + youtube_str = '0.75_BAD!!!,1.0:AXdE34_U,1.25:KLHF9K_Y,1.5:VO3SxfeD,' + output = VideoDescriptor._parse_youtube(youtube_str) + self.assertEqual(output, {'0.75': '', + '1.00': 'AXdE34_U', + '1.25': 'KLHF9K_Y', + '1.50': 'VO3SxfeD'}) + def test_parse_youtube_key_format(self): """ Make sure that inconsistent speed keys are parsed correctly.