예제 #1
0
 def test_get_no_video_exists(self, cdn_response):
     """
     Test if no alternative video in CDN exists.
     """
     original_video_url = "http://www.original_video.com/original_video.mp4"
     cdn_response.return_value = Mock(status_code=404)
     fake_cdn_url = 'http://fake_cdn.com/'
     self.assertIsNone(get_video_from_cdn(fake_cdn_url, original_video_url))
예제 #2
0
 def test_get_no_video_exists(self, cdn_response):
     """
     Test if no alternative video in CDN exists.
     """
     original_video_url = "http://www.original_video.com/original_video.mp4"
     cdn_response.return_value = Mock(status_code=404)
     fake_cdn_url = 'http://fake_cdn.com/'
     self.assertIsNone(get_video_from_cdn(fake_cdn_url, original_video_url))
예제 #3
0
 def test_get_video_success(self, cdn_response):
     """
     Test successful CDN request.
     """
     original_video_url = "http://www.original_video.com/original_video.mp4"
     cdn_response_video_url = "http://www.cdn_video.com/cdn_video.mp4"
     cdn_response_content = '{{"sources":["{cdn_url}"]}}'.format(
         cdn_url=cdn_response_video_url)
     cdn_response.return_value = Mock(status_code=200,
                                      content=cdn_response_content)
     fake_cdn_url = 'http://fake_cdn.com/'
     self.assertEqual(get_video_from_cdn(fake_cdn_url, original_video_url),
                      cdn_response_video_url)
예제 #4
0
 def test_get_video_success(self, cdn_response):
     """
     Test successful CDN request.
     """
     original_video_url = "http://www.original_video.com/original_video.mp4"
     cdn_response_video_url = "http://www.cdn_video.com/cdn_video.mp4"
     cdn_response_content = '{{"sources":["{cdn_url}"]}}'.format(cdn_url=cdn_response_video_url)
     cdn_response.return_value = Mock(status_code=200, content=cdn_response_content)
     fake_cdn_url = 'http://fake_cdn.com/'
     self.assertEqual(
         get_video_from_cdn(fake_cdn_url, original_video_url),
         cdn_response_video_url
     )