def test_get_position_after_element_returns_expected_position( self, source: str, element_name: str, expected_position: Position ) -> None: document = TestUtils.to_document(source) tool = GalaxyToolXmlDocument(document) element = tool.find_element(element_name, maxlevel=4) assert element is not None actual_position = tool.get_position_after(element) assert actual_position == expected_position
def _find_macros_insert_position(self, tool: GalaxyToolXmlDocument) -> Position: """Returns the position inside the document where the macros section can be inserted. Returns: Range: The position where the macros section can be inserted in the document. """ section = tool.find_element(XREF) if section: return tool.get_position_after(section) section = tool.find_element(DESCRIPTION) if section: return tool.get_position_after(section) root = tool.find_element(TOOL) content_range = tool.get_content_range(root) if content_range: return content_range.start return Position(line=0, character=0)