def test_getTextContent_no_childNodes(self): """Tests getTextContent when it has no childNodes""" _node = MagicMock() _childNodes = PropertyMock(return_value=iter([])) type(_node).childNodes = _childNodes _element = Element(_node) _result = _element.getTextContent() self.assertIsNone(_result) _childNodes.assert_called_once()
def test_getTextContent_returns_text(self): """Tests getTextContent when it has proper data""" _node = MagicMock() _childNodes = PropertyMock(return_value=iter([InnerNode(0, '0'), InnerNode( 3, '3'), InnerNode(3, '16'), InnerNode(1, '1')])) type(_node).childNodes = _childNodes _element = Element(_node) _result = _element.getTextContent() self.assertEqual(_result, '3\n16') _childNodes.assert_called_once()
def test_getTextContent_has_childNodes_but_without_expected_nodeType(self): """Tests getTextContent whith childNodes""" _node = MagicMock() _childNodes = PropertyMock(return_value=iter( [InnerNode(0, '0'), InnerNode(1, '1')])) type(_node).childNodes = _childNodes _element = Element(_node) _result = _element.getTextContent() self.assertIsNone(_result) _childNodes.assert_called_once()