def test_success_downloading_subs(self): # Disabled 11/14/13 # This test is flakey because it performs an HTTP request on an external service # Re-enable when `requests.get` is patched using `mock.patch` raise SkipTest good_youtube_subs = { 0.5: 'JMD_ifUUfsU', 1.0: 'hI10vDNYz4M', 2.0: 'AKqURZnYqpk' } self.clear_subs_content(good_youtube_subs) # Check transcripts_utils.GetTranscriptsFromYouTubeException not thrown transcripts_utils.download_youtube_subs(good_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in good_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename) self.assertTrue(contentstore().find(content_location)) self.clear_subs_content(good_youtube_subs)
def test_fail_downloading_subs(self): # Disabled 11/14/13 # This test is flakey because it performs an HTTP request on an external service # Re-enable when `requests.get` is patched using `mock.patch` raise SkipTest bad_youtube_subs = { 0.5: 'BAD_YOUTUBE_ID1', 1.0: 'BAD_YOUTUBE_ID2', 2.0: 'BAD_YOUTUBE_ID3' } self.clear_subs_content(bad_youtube_subs) with self.assertRaises( transcripts_utils.GetTranscriptsFromYouTubeException): transcripts_utils.download_youtube_subs(bad_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in bad_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename) with self.assertRaises(NotFoundError): contentstore().find(content_location) self.clear_subs_content(bad_youtube_subs)
def test_fail_downloading_subs(self): # Disabled 11/14/13 # This test is flakey because it performs an HTTP request on an external service # Re-enable when `requests.get` is patched using `mock.patch` raise SkipTest bad_youtube_subs = { 0.5: 'BAD_YOUTUBE_ID1', 1.0: 'BAD_YOUTUBE_ID2', 2.0: 'BAD_YOUTUBE_ID3' } self.clear_subs_content(bad_youtube_subs) with self.assertRaises(transcripts_utils.GetTranscriptsFromYouTubeException): transcripts_utils.download_youtube_subs(bad_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in bad_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename ) with self.assertRaises(NotFoundError): contentstore().find(content_location) self.clear_subs_content(bad_youtube_subs)
def test_success_downloading_subs(self): # Disabled 11/14/13 # This test is flakey because it performs an HTTP request on an external service # Re-enable when `requests.get` is patched using `mock.patch` raise SkipTest good_youtube_subs = { 0.5: 'JMD_ifUUfsU', 1.0: 'hI10vDNYz4M', 2.0: 'AKqURZnYqpk' } self.clear_subs_content(good_youtube_subs) # Check transcripts_utils.GetTranscriptsFromYouTubeException not thrown transcripts_utils.download_youtube_subs(good_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in good_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename ) self.assertTrue(contentstore().find(content_location)) self.clear_subs_content(good_youtube_subs)
def test_success_downloading_chinise_transcripts(self): good_youtube_subs = { 1.0: 'j_jEn79vS3g', # Chinese, utf-8 } self.clear_subs_content(good_youtube_subs) # Check transcripts_utils.GetTranscriptsFromYouTubeException not thrown transcripts_utils.download_youtube_subs(good_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in good_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename) self.assertTrue(contentstore().find(content_location)) self.clear_subs_content(good_youtube_subs)
def test_success_downloading_chinise_transcripts(self): good_youtube_subs = { 1.0: 'j_jEn79vS3g', # Chinese, utf-8 } self.clear_subs_content(good_youtube_subs) # Check transcripts_utils.GetTranscriptsFromYouTubeException not thrown transcripts_utils.download_youtube_subs(good_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in good_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename ) self.assertTrue(contentstore().find(content_location)) self.clear_subs_content(good_youtube_subs)
def test_success_downloading_subs(self): good_youtube_subs = { 0.5: 'JMD_ifUUfsU', 1.0: 'hI10vDNYz4M', 2.0: 'AKqURZnYqpk' } self.clear_subs_content(good_youtube_subs) # Check transcripts_utils.GetTranscriptsFromYouTubeException not thrown transcripts_utils.download_youtube_subs(good_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in good_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename) self.assertTrue(contentstore().find(content_location)) self.clear_subs_content(good_youtube_subs)
def test_success_downloading_subs(self): good_youtube_subs = { 0.5: 'JMD_ifUUfsU', 1.0: 'hI10vDNYz4M', 2.0: 'AKqURZnYqpk' } self.clear_subs_content(good_youtube_subs) # Check transcripts_utils.GetTranscriptsFromYouTubeException not thrown transcripts_utils.download_youtube_subs(good_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in good_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename ) self.assertTrue(contentstore().find(content_location)) self.clear_subs_content(good_youtube_subs)
def test_fail_downloading_subs(self): bad_youtube_subs = { 0.5: 'BAD_YOUTUBE_ID1', 1.0: 'BAD_YOUTUBE_ID2', 2.0: 'BAD_YOUTUBE_ID3' } self.clear_subs_content(bad_youtube_subs) with self.assertRaises(transcripts_utils.GetTranscriptsFromYouTubeException): transcripts_utils.download_youtube_subs(bad_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in bad_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename ) with self.assertRaises(NotFoundError): contentstore().find(content_location) self.clear_subs_content(bad_youtube_subs)
def test_fail_downloading_subs(self): bad_youtube_subs = { 0.5: 'BAD_YOUTUBE_ID1', 1.0: 'BAD_YOUTUBE_ID2', 2.0: 'BAD_YOUTUBE_ID3' } self.clear_subs_content(bad_youtube_subs) with self.assertRaises( transcripts_utils.GetTranscriptsFromYouTubeException): transcripts_utils.download_youtube_subs(bad_youtube_subs, self.course) # Check assets status after importing subtitles. for subs_id in bad_youtube_subs.values(): filename = 'subs_{0}.srt.sjson'.format(subs_id) content_location = StaticContent.compute_location( self.org, self.number, filename) with self.assertRaises(NotFoundError): contentstore().find(content_location) self.clear_subs_content(bad_youtube_subs)