def test_append_multi(self): x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>') y = XQuery('<R><a>1<c><d>6</d></c></a><a>2<c><d>6</d></c></a><b>3</b></R>') z = XQuery('<c><d>6</d></c>') x.find('a').append(z) self.assertEquals(y, x)
def test_find(self): x = XQuery('''<R><a>1</a><b>2</b></R>''') self.assertEquals(XQuery('<a>1</a>'), x.find('a'))
def test_text(self): x = XQuery('<R><a>1</a><a><c>4</c></a><b>3</b></R>') self.assertEquals('4', x.find('c').text())
def test_chain(self): x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>') x.find('a').append(XQuery('<c/>')).find('c').text("4") self.assertEquals(XQuery('<R><a>1<c>4</c></a><a>2<c>4</c></a><b>3</b></R>'), x)
def test_empty_append(self): x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>') x.find('c').append(XQuery('<d/>')) self.assertEquals(XQuery('<R><a>1</a><a>2</a><b>3</b></R>'), x)
def test_find_empty(self): x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>') self.assertEquals([], x.find('c'))
def test_append(self): x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>') y = XQuery('<R><a>1<c/></a><a>2<c/></a><b>3</b></R>') x.find('a').append(XQuery('<c/>')) self.assertEquals(y, x)
def test_find(self): x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>') y = x.find('R').find('a').text() self.assertEquals(['1','2'], y)
def test_find_multi(self): x = XQuery('<R><a><c>4</c></a><a>2</a><b>3</b></R>') y = x.find('a').find('c').text() self.assertEquals('4', y)
def test_modfity_text_of_node_that_is_not_exists(self): x = XQuery('<a>1</a>') x.find('b').text('2') self.assertEquals(XQuery('<a>1</a>'), x)
def test_empty_text(self): x = XQuery('<R><a>1</a><a><c>4</c></a><b>3</b></R>') self.assertEquals([], x.find('d').text())
def test_append_multi(self): x = XQuery('<R><a/><c><a/></c></R>') x.find('a').append(XQuery('<b/>')) self.assertEquals(XQuery('<R><a><b/></a><c><a><b/></a></c></R>'), x)
def test_text_multi(self): x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>') self.assertEquals(['1', '2'],x.find('a').text())
def test_find_not_exists(self): x = XQuery('<R/>') self.assertEquals([], x.find('a'))