Ejemplo n.º 1
0
 def test_addIdAttribute_no_op(self):
     """Tests addIdAttribute when node has attribute already"""
     _node = MagicMock()
     _node.hasAttribute.return_value = True
     _element = Element(_node)
     _result = _element.addIdAttribute('some')
     self.assertIsNone(_result)
     _node.hasAttribute.assert_called_once_with('some')
     _node.setAttribute.assert_not_called()
     _node.setIdAttribute.assert_not_called()
Ejemplo n.º 2
0
 def test_addIdAttribute_has_document_owner(self):
     """Tests addIdAttribute when node has attribute already and has owner of document"""
     _node = MagicMock()
     _node.hasAttribute.return_value = False
     _generate_id_mock = self._init_patch_with_name(
         '_generate_id', 'xmind.core.utils.generate_id', return_value=2, autospec=True)
     _get_owner_document = self._init_patch_with_name(
         '_getOwnerDocument', 'xmind.core.Element.getOwnerDocument', return_value=True, autospec=True)
     _element = Element(_node)
     _result = _element.addIdAttribute('some')
     self.assertIsNone(_result)
     _generate_id_mock.assert_called_once()
     _node.hasAttribute.assert_called_once_with('some')
     _node.setAttribute.assert_called_once_with('some', 2)
     _node.setIdAttribute.assert_called_once_with('some')
     _get_owner_document.assert_called_once()