'Test content with rendered bumper metadata.'

@patch('xmodule.video_module.bumper_utils.is_bumper_enabled')
@patch('xmodule.video_module.bumper_utils.get_bumper_settings')
@patch('edxval.api.get_urls_for_profiles')
def test_bumper_metadata(self, get_url_for_profiles, get_bumper_settings, is_bumper_enabled):

    get_url_for_profiles.return_value = {'desktop_mp4': 'http://test_bumper.mp4', 'desktop_webm': ''}
    get_bumper_settings.return_value = {'video_id': 'edx_video_id', 'transcripts': {}}
    is_bumper_enabled.return_value = True
    content = self.item_descriptor.render(STUDENT_VIEW).content
    sources = [u'example.mp4', u'example.webm']
    expected_context = {'branding_info': None, 'license': None, 'bumper_metadata': json.dumps(OrderedDict({'saveStateUrl': (self.item_descriptor.xmodule_runtime.ajax_url + '/save_user_state'), 'showCaptions': 'true', 'sources': ['http://test_bumper.mp4'], 'streams': '', 'transcriptLanguage': 'en', 'transcriptLanguages': {'en': 'English'}, 'transcriptTranslationUrl': video_utils.set_query_parameter(self.item_descriptor.xmodule_runtime.handler_url(self.item_descriptor, 'transcript', 'translation/__lang__').rstrip('/?'), 'is_bumper', 1), 'transcriptAvailableTranslationsUrl': video_utils.set_query_parameter(self.item_descriptor.xmodule_runtime.handler_url(self.item_descriptor, 'transcript', 'available_translations').rstrip('/?'), 'is_bumper', 1)})), 'cdn_eval': False, 'cdn_exp_group': None, 'display_name': u'A    Name', 'download_video_link': u'example.mp4', 'handout': None, 'id': self.item_descriptor.location.html_id(), 'metadata': json.dumps(OrderedDict({'saveStateUrl': (self.item_descriptor.xmodule_runtime.ajax_url + '/save_user_state'), 'autoplay': False, 'streams': '0.75:jNCf2gIqpeE,1.00:ZwkTiUPN0mg,1.25:rsq9auxASqI,1.50:kMyNdzVHHgg', 'sub': 'a_sub_file.srt.sjson', 'sources': sources, 'poster': None, 'captionDataDir': None, 'showCaptions': 'true', 'generalSpeed': 1.0, 'speed': None, 'savedVideoPosition': 0.0, 'start': 3603.0, 'end': 3610.0, 'transcriptLanguage': 'en', 'transcriptLanguages': OrderedDict({'en': 'English', 'uk': u'\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430'}), 'ytTestTimeout': 1500, 'ytApiUrl': 'https://www.youtube.com/iframe_api', 'ytMetadataUrl': 'https://www.googleapis.com/youtube/v3/videos/', 'ytKey': None, 'transcriptTranslationUrl': self.item_descriptor.xmodule_runtime.handler_url(self.item_descriptor, 'transcript', 'translation/__lang__').rstrip('/?'), 'transcriptAvailableTranslationsUrl': self.item_descriptor.xmodule_runtime.handler_url(self.item_descriptor, 'transcript', 'available_translations').rstrip('/?'), 'autohideHtml5': False, 'recordedYoutubeIsAvailable': True})), 'track': None, 'transcript_download_format': u'srt', 'transcript_download_formats_list': [{'display_name': 'SubRip    (.srt)    file', 'value': 'srt'}, {'display_name': 'Text    (.txt)    file', 'value': 'txt'}], 'poster': json.dumps(OrderedDict({'url': 'http://img.youtube.com/vi/ZwkTiUPN0mg/0.jpg', 'type': 'youtube'}))}
    expected_content = self.item_descriptor.xmodule_runtime.render_template('video.html', expected_context)
    self.assertEqual(content, expected_content)
