Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    def test_getVideoObject_should_get_video_information_from_getVideoInfo(self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        player = VimeoPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = ({}, 303)
        player._getVideoLinks = Mock()
        player._getVideoLinks.return_value = ({}, {})

        player.getVideoObject({})

        player.getVideoInfo.assert_called_with({})
Ejemplo n.º 3
0
    def test_getVideoObject_should_get_video_information_from_getVideoInfo(
            self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        player = VimeoPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = ({}, 303)
        player._getVideoLinks = Mock()
        player._getVideoLinks.return_value = ({}, {})

        player.getVideoObject({})

        player.getVideoInfo.assert_called_with({})
Ejemplo n.º 4
0
    def test_getVideoObject_should_check_for_local_file_if_download_path_is_set(self):
        params = {"videoid": "some_id"}
        sys.modules["__main__"].settings.getSetting.return_value = "somePath/"
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        player = VimeoPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = ({"videoid": "some_id", "Title": "someTitle"}, 200)
        player._getVideoLinks = Mock()
        player._getVideoLinks.return_value = ({}, {})

        player.getVideoObject(params)

        sys.modules["__main__"].xbmcvfs.exists.assert_called_with("somePath/someTitle-[some_id].mp4")
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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")
Ejemplo n.º 7
0
    def test_getVideoObject_should_use_local_file_for_playback_if_found(self):
        sys.modules["__main__"].settings.getSetting.return_value = "somePath/"
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        params = {"videoid": "some_id"}
        player = VimeoPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = ({"videoid": "some_id", "Title": "someTitle"}, 200)
        player._getVideoLinks = Mock()
        player._getVideoLinks.return_value = ({}, {})

        (video, status) = player.getVideoObject(params)

        sys.modules["__main__"].xbmcvfs.exists.assert_called_with("somePath/someTitle-[some_id].mp4")
        assert(player._getVideoLinks.call_count == 0)
        assert(video["video_url"] == "somePath/someTitle-[some_id].mp4")
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
    def test_getVideoObject_should_check_for_local_file_if_download_path_is_set(
            self):
        params = {"videoid": "some_id"}
        sys.modules["__main__"].settings.getSetting.return_value = "somePath/"
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        player = VimeoPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = ({
            "videoid": "some_id",
            "Title": "someTitle"
        }, 200)
        player._getVideoLinks = Mock()
        player._getVideoLinks.return_value = ({}, {})

        player.getVideoObject(params)

        sys.modules["__main__"].xbmcvfs.exists.assert_called_with(
            "somePath/someTitle-[some_id].mp4")
Ejemplo n.º 11
0
    def test_getVideoObject_should_use_local_file_for_playback_if_found(self):
        sys.modules["__main__"].settings.getSetting.return_value = "somePath/"
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        params = {"videoid": "some_id"}
        player = VimeoPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = ({
            "videoid": "some_id",
            "Title": "someTitle"
        }, 200)
        player._getVideoLinks = Mock()
        player._getVideoLinks.return_value = ({}, {})

        (video, status) = player.getVideoObject(params)

        sys.modules["__main__"].xbmcvfs.exists.assert_called_with(
            "somePath/someTitle-[some_id].mp4")
        assert (player._getVideoLinks.call_count == 0)
        assert (video["video_url"] == "somePath/someTitle-[some_id].mp4")
Ejemplo n.º 12
0
    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"
        )