def test_setVersion_version_has_been_already_set(self):
     """Tests setVersion method when version has been set before"""
     _documentElement = MagicMock()
     _documentElement.hasAttribute.return_value = True
     _node = MagicMock(documentElement=_documentElement)
     _document = Document(_node)  # value has to be taken from parameter
     _document.setVersion('123')
     _documentElement.setAttribute.assert_not_called()
     _documentElement.hasAttribute.assert_called_once_with("version")
 def test_setVersion(self):
     """Tests setVersion method"""
     _documentElement = MagicMock()
     _documentElement.hasAttribute.return_value = False
     _node = MagicMock(documentElement=_documentElement)
     _document = Document(_node)  # value has to be taken from parameter
     _document.setVersion('123')
     _documentElement.setAttribute.assert_called_once_with("version", '123')
     _documentElement.hasAttribute.assert_called_once_with("version")
 def test_setVersion_no_element(self):
     """Tests setVersion method documentElement is None, no exception should be"""
     _node = MagicMock(documentElement=None)
     _document = Document(_node)  # value has to be taken from parameter
     _document.setVersion("123")