def test_getVideoObject_should_test_local_file(self):
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        sys.modules["__main__"].xbmcvfs.exists.return_value
        sys.modules["__main__"].settings.getSetting.return_value = "mock_path/"
        player = BlipTVPlayer()
        player.selectVideoQuality = Mock()
        player.selectVideoQuality.return_value = "video-url"
        player._getVideoLinks = Mock()
        player.getInfo = Mock()
        player.getInfo.return_value = {"Title": "mock"}
        
        (video, status) = player.getVideoObject({"action": "check-local", "videoid": "mockid"})

        sys.modules["__main__"].xbmcvfs.exists.assert_called_with('mock_path/mock-[mockid].mp4')
    def test__getVideoLinks_should_return_1080p(self):
        patcher = patch("xml.dom.minidom.parseString")
        patcher.start()
        import xml.dom.minidom
        node = Mock()
        node.getAttribute = Mock()
        node_ret = ["1080", "1080-url","something_video"]
        node.getAttribute.side_effect = lambda x: node_ret.pop()
        dom = Mock()
        dom.getElementsByTagName.return_value = [node]
        xml.dom.minidom.parseString = Mock()
        xml.dom.minidom.parseString.return_value = dom
        player = BlipTVPlayer()
        
        links = player._getVideoLinks({"status": 200, "content": "content"}, {})

        assert(links["1080p"] == "1080-url")
    def test_getVideoObject_should_fail(self):
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        sys.modules["__main__"].settings.getSetting.return_value = "mock_path/"
        sys.modules["__main__"].language.return_value = "mock error"
        player = BlipTVPlayer()
        player.selectVideoQuality = Mock()
        player.selectVideoQuality.return_value = "video-url"
        player._getVideoLinks = Mock()
        player._getVideoLinks.return_value = False
        player.getInfo = Mock()
        player.getInfo.return_value = {}

        params = {"action": "play", "videoid": "mockid"}
        video = player.getVideoObject(params)
        print "A : " + repr(video)
        print "B : " + repr(params)
        assert(params["apierror"] == "mock error")
    def test_getVideoObject_should_return_correctly(self):
        patcher = patch("urllib2.urlopen")
        patcher.start()
        import urllib2
        urllib2.urlopen().geturl = Mock(return_value="real-video-url")
        player = BlipTVPlayer()
        player.selectVideoQuality = Mock()
        player.selectVideoQuality.return_value = "video-url"
        player._getVideoLinks = Mock()
        player.getInfo = Mock()
        player.getInfo.return_value = {"Title": "mock"}

        video = player.getVideoObject({"action": "download"})
        patcher.stop()

        print "A : " + repr(video)
        assert(video["Title"] == "mock")
        assert(video["video_url"] == "real-video-url")