def test_getVideoInfo_calls_storage(self):
        patcher = patch("xml.dom.minidom.parseString")
        patcher.start()
        import xml.dom.minidom
        dom = Mock()
        xml.dom.minidom.parseString = Mock()
        xml.dom.minidom.parseString.return_value = dom
        dom.getElementsByTagName.return_value = [{}]
        player = BlipTVPlayer()
        player._getNodeValue = Mock()
        player.storage = Mock()
        player.storage.retrieveValue.return_value = "0"

        player.getVideoInfo("xml", {"videoid": "vidid"})
        patcher.stop()

        player.storage.retrieveValue.assert_called_with("vidstatus-vidid")
    def test_getInfo_should_call_log_error_if_getVideoInfo_fails(self):
        sys.modules["__main__"].cache.sqlGet.return_value = {}
        sys.modules["__main__"].common.fetchPage.return_value = {"status": 200, "content": "something"}
        player = BlipTVPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = {}

        player.getInfo({"content": "content", "status": 200})

        sys.modules["__main__"].common.log.assert_any_call("Couldn't parse API output, BlipTV doesn't seem to know this video id?")
    def test_getInfo_should_call_core_getVideoInfo_to_parse_bliptv_data(self):
        sys.modules["__main__"].cache.sqlGet.return_value = {}
        sys.modules["__main__"].common.fetchPage.return_value = {"status": 200, "content": "something"}
        sys.modules["__main__"].player.getVideoInfo.return_value = [{"videoid": "some_id"}]
        player = BlipTVPlayer()
        player.getVideoInfo = Mock()
        player.getVideoInfo.return_value = {"id": "some_id"}

        player.getInfo({"content": "content", "status": 200})

        player.getVideoInfo.assert_called_with('content', {})
    def test_getVideoInfo_calls_minidom(self):
        patcher = patch("xml.dom.minidom.parseString")
        patcher.start()
        import xml.dom.minidom
        dom = Mock()
        xml.dom.minidom.parseString = Mock()
        xml.dom.minidom.parseString.return_value = dom
        dom.getElementsByTagName.return_value = [{}]
        player = BlipTVPlayer()
        player._getNodeValue = Mock()
        player.storage = Mock()
        player.storage.retrieveValue.return_value = "0"

        result = player.getVideoInfo("xml", {"videoid": "vidid"})
        patcher.stop()

        print repr(result)
        print repr(player._getNodeValue.call_count)
        assert(player._getNodeValue.call_count == 6)