def test_getNodeValue_should_parse_node_structure_correctly(self):
        settings = ["3"]
        sys.modules["__main__"].settings.getSetting.side_effect = lambda x: settings.pop()
        player = BlipTVPlayer()
        node = Mock()
        node.getElementsByTagName().item().firstChild.nodeValue = 5

        result = player._getNodeValue(node, "tag", "default")

        node.getElementsByTagName.assert_called_with("tag")
        node.getElementsByTagName().item.assert_called_with(0)
        assert(result == 5)
    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_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)