def test_rename_node(self): left = u'<document><node><para>Content</para>Tail</node></document>' action = actions.RenameNode('/document/node[1]/para[1]', 'newtag') expected = START + u'><newtag diff:rename="para">Content'\ '</newtag>Tail' + END self._format_test(left, action, expected)
def test_rename_node(self): # Move 1 down action = actions.RenameNode("/document/node[1]", "newtag") expected = "[rename, /document/node[1], newtag]" self._format_test(action, expected) # Move 2 up (same result, different diff) action = actions.MoveNode("/document/node[2]", "/document", 0) expected = "[move-first, /document/node[2], /document]" self._format_test(action, expected)
def test_rename_node(self): # Move 1 down action = actions.RenameNode('/document/node[1]', 'newtag') expected = '[rename, /document/node[1], newtag]' self._format_test(action, expected) # Move 2 up (same result, different diff) action = actions.MoveNode('/document/node[2]', '/document', 0) expected = '[move-first, /document/node[2], /document]' self._format_test(action, expected)
def update_node_tag(self, left, right): if left.tag != right.tag: left_xpath = utils.getpath(left) yield actions.RenameNode(left_xpath, right.tag) left.tag = right.tag
def test_rename_node(self): left = "<document><node><para>Content</para>Tail</node></document>" action = actions.RenameNode("/document/node[1]/para[1]", "newtag") expected = START + '><newtag diff:rename="para">Content' "</newtag>Tail" + END self._format_test(left, action, expected)
def _handle_rename(self, node, tag): return actions.RenameNode(node, tag)