def test_selectVideoQuality_should_call_userSelectsVideoQuality_if_user_selected_that_option(self): sys.modules["__main__"].settings.getSetting.return_value = "0" player = VimeoPlayer() player.userSelectsVideoQuality = Mock() player.selectVideoQuality({}, {"isHD":"1"}) player.userSelectsVideoQuality.assert_called_with({})
def test_selectVideoQuality_should_call_userSelectsVideoQuality_if_user_selected_that_option( self): sys.modules["__main__"].settings.getSetting.return_value = "0" player = VimeoPlayer() player.userSelectsVideoQuality = Mock() player.selectVideoQuality({}, {"isHD": "1"}) player.userSelectsVideoQuality.assert_called_with({})
def test_selectVideoQuality_should_prefer_SD_if_asked_to(self): sys.modules["__main__"].settings.getSetting.return_value = "2" player = VimeoPlayer() url = player.selectVideoQuality({}, {}) assert(url == "sd")
def test_selectVideoQuality_should_limit_to_sd_if_user_has_selected_that_option(self): sys.modules["__main__"].settings.getSetting.return_value = "1" player = VimeoPlayer() url = player.selectVideoQuality({"isHD":"1"}, {}) assert(url == "sd")
def test_getVideoObject_should_call_fetchPage_if_local_file_not_found( self): params = {"videoid": "some_id"} sys.modules["__main__"].settings.getSetting.return_value = "somePath/" sys.modules["__main__"].xbmcvfs.exists.return_value = False sys.modules["__main__"].common.fetchPage.return_value = { "new_url": "some_url" } player = VimeoPlayer() player.getVideoInfo = Mock() player.getVideoInfo.return_value = ({ "videoid": "some_id", "Title": "someTitle", "request_signature": "signature", "request_signature_expires": "2" }, 200) player._getVideoLinks = Mock() player.selectVideoQuality = Mock() player._getVideoLinks.return_value = ({}, {}) (video, status) = player.getVideoObject(params) sys.modules["__main__"].xbmcvfs.exists.assert_called_with( "somePath/someTitle-[some_id].mp4") assert (sys.modules["__main__"].common.fetchPage.call_count > 0)
def test_selectVideoQuality_should_use_hd_videos_download_setting_to_determine_video_quality_if_action_is_download(self): sys.modules["__main__"].settings.getSetting.return_value = "1" player = VimeoPlayer() url = player.selectVideoQuality({"isHD":"1", "action":"download"}, {}) sys.modules["__main__"].settings.getSetting.assert_any_call("hd_videos_download")
def test_selectVideoQuality_should_prefer_SD_if_asked_to(self): sys.modules["__main__"].settings.getSetting.return_value = "2" player = VimeoPlayer() url = player.selectVideoQuality({}, {}) assert (url == "sd")
def test_selectVideoQuality_should_choose_sd_if_quality_is_set(self): sys.modules["__main__"].settings.getSetting.return_value = 2 player = VimeoPlayer() url = player.selectVideoQuality({"isHD": "1", "quality": "sd"}, {}) print repr(url) assert (url == "sd")
def test_selectVideoQuality_should_limit_to_sd_if_user_has_selected_that_option( self): sys.modules["__main__"].settings.getSetting.return_value = "1" player = VimeoPlayer() url = player.selectVideoQuality({"isHD": "1"}, {}) assert (url == "sd")
def test_selectVideoQuality_should_choose_sd_if_quality_is_set(self): sys.modules["__main__"].settings.getSetting.return_value = 2 player = VimeoPlayer() url = player.selectVideoQuality({"isHD":"1", "quality":"sd"}, {}) print repr(url) assert(url == "sd")
def test_selectVideoQuality_should_prefer_720p_if_asked_to(self): sys.modules["__main__"].settings.getSetting.return_value = 2 player = VimeoPlayer() url = player.selectVideoQuality({},{"isHD":"1"}) print repr(url) assert(url == "hd")
def test_selectVideoQuality_should_prefer_720p_if_asked_to(self): sys.modules["__main__"].settings.getSetting.return_value = 2 player = VimeoPlayer() url = player.selectVideoQuality({}, {"isHD": "1"}) print repr(url) assert (url == "hd")
def test_selectVideoQuality_should_use_default_to_hd_videos_setting_if_hd_videos_download_is_unset_and_action_is_download(self): sys.modules["__main__"].settings.getSetting.side_effect = ["0","1"] player = VimeoPlayer() url = player.selectVideoQuality({"isHD":"1", "action":"download"}, {}) sys.modules["__main__"].settings.getSetting.assert_any_call("hd_videos_download") sys.modules["__main__"].settings.getSetting.assert_any_call("hd_videos")
def test_selectVideoQuality_should_use_hd_videos_download_setting_to_determine_video_quality_if_action_is_download( self): sys.modules["__main__"].settings.getSetting.return_value = "1" player = VimeoPlayer() url = player.selectVideoQuality({ "isHD": "1", "action": "download" }, {}) sys.modules["__main__"].settings.getSetting.assert_any_call( "hd_videos_download")
def test_getVideoObject_should_use_return_api_error_if_video_info_fails(self): sys.modules["__main__"].settings.getSetting.return_value = "" sys.modules["__main__"].common.fetchPage.return_value = {"new_url":""} player = VimeoPlayer() player.getVideoInfo = Mock() player.getVideoInfo.return_value = ({"apierror":"fail"}, 303) player._getVideoLinks = Mock() player._getVideoLinks.return_value = ({}, {}) player.selectVideoQuality = Mock() (result, status) = player.getVideoObject({}) assert (result == "fail") assert (status == 303)
def test_getVideoObject_should_handle_accents_and_utf8(self): params = {"videoid": "some_id"} sys.modules["__main__"].settings.getSetting.return_value = u"somePathé/".encode("utf-8") sys.modules["__main__"].xbmcvfs.exists.return_value = True player = VimeoPlayer() player.getVideoInfo = Mock() player.getVideoInfo.return_value = ({"videoid": "some_id", "Title": u"נלה מהיפה והחנון בסטריפ צ'אט בקליפ של חובבי ציון"}, 200) player._getVideoLinks = Mock() player._getVideoLinks.return_value = ([], {}) player.selectVideoQuality = Mock() (video, status) = player.getVideoObject(params) sys.modules["__main__"].xbmcvfs.exists.assert_called_with(u"somePath\xe9/\u05e0\u05dc\u05d4 \u05de\u05d4\u05d9\u05e4\u05d4 \u05d5\u05d4\u05d7\u05e0\u05d5\u05df \u05d1\u05e1\u05d8\u05e8\u05d9\u05e4 \u05e6'\u05d0\u05d8 \u05d1\u05e7\u05dc\u05d9\u05e4 \u05e9\u05dc \u05d7\u05d5\u05d1\u05d1\u05d9 \u05e6\u05d9\u05d5\u05df-[some_id].mp4")
def test_selectVideoQuality_should_use_default_to_hd_videos_setting_if_hd_videos_download_is_unset_and_action_is_download( self): sys.modules["__main__"].settings.getSetting.side_effect = ["0", "1"] player = VimeoPlayer() url = player.selectVideoQuality({ "isHD": "1", "action": "download" }, {}) sys.modules["__main__"].settings.getSetting.assert_any_call( "hd_videos_download") sys.modules["__main__"].settings.getSetting.assert_any_call( "hd_videos")
def test_getVideoObject_should_call_selectVideoQuality_if_local_file_not_found_and_remote_links_found(self): params = {"videoid": "some_id"} sys.modules["__main__"].settings.getSetting.return_value = "somePath/" sys.modules["__main__"].xbmcvfs.exists.return_value = False sys.modules["__main__"].common.fetchPage.return_value = {"new_url":"some_url"} player = VimeoPlayer() player.getVideoInfo = Mock() video = {"videoid": "some_id", "Title": "someTitle", "request_signature":"signature", "request_signature_expires":"2"} player.getVideoInfo.return_value = (video, 200) player.selectVideoQuality = Mock() (video, status) = player.getVideoObject(params) sys.modules["__main__"].xbmcvfs.exists.assert_called_with("somePath/someTitle-[some_id].mp4") player.selectVideoQuality.assert_called_with(params, video)
def test_getVideoObject_should_use_return_api_error_if_video_info_fails( self): sys.modules["__main__"].settings.getSetting.return_value = "" sys.modules["__main__"].common.fetchPage.return_value = {"new_url": ""} player = VimeoPlayer() player.getVideoInfo = Mock() player.getVideoInfo.return_value = ({"apierror": "fail"}, 303) player._getVideoLinks = Mock() player._getVideoLinks.return_value = ({}, {}) player.selectVideoQuality = Mock() (result, status) = player.getVideoObject({}) assert (result == "fail") assert (status == 303)
def test_getVideoObject_should_handle_accents_and_utf8(self): params = {"videoid": "some_id"} sys.modules[ "__main__"].settings.getSetting.return_value = u"somePathé/".encode( "utf-8") sys.modules["__main__"].xbmcvfs.exists.return_value = True player = VimeoPlayer() player.getVideoInfo = Mock() player.getVideoInfo.return_value = ({ "videoid": "some_id", "Title": u"נלה מהיפה והחנון בסטריפ צ'אט בקליפ של חובבי ציון" }, 200) player._getVideoLinks = Mock() player._getVideoLinks.return_value = ([], {}) player.selectVideoQuality = Mock() (video, status) = player.getVideoObject(params) sys.modules["__main__"].xbmcvfs.exists.assert_called_with( u"somePath\xe9/\u05e0\u05dc\u05d4 \u05de\u05d4\u05d9\u05e4\u05d4 \u05d5\u05d4\u05d7\u05e0\u05d5\u05df \u05d1\u05e1\u05d8\u05e8\u05d9\u05e4 \u05e6'\u05d0\u05d8 \u05d1\u05e7\u05dc\u05d9\u05e4 \u05e9\u05dc \u05d7\u05d5\u05d1\u05d1\u05d9 \u05e6\u05d9\u05d5\u05df-[some_id].mp4" )