Esempio n. 1
0
    def test_remove_desendent(self):
        x = XQuery('''<R><a>1</a><b><c>3</c></b></R>''')

        self.assertEquals(XQuery('<c>3</c>'),
                          x.remove('c'))
        self.assertEquals(XQuery('<R><a>1</a><b></b></R>'),
                          x)
Esempio n. 2
0
    def test_remove_child(self):
        x = XQuery('''<R><a>1</a><b><c>3</c></b></R>''')

        self.assertEquals(XQuery('<b><c>3</c></b>'),
                          x.remove('b'))
        self.assertEquals(XQuery('<R><a>1</a></R>'),
                          x)
Esempio n. 3
0
    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)
Esempio n. 4
0
    def test_eq_cdata2(self):
        a = etree.Element('root')
        a.text = '<root><a>1</a></root>'

        b = etree.Element('root')
        b.text = etree.CDATA('<root><a>1</a></root>')

        self.assertTrue(XQuery.is_etree_node_eq(a, b))
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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)
Esempio n. 8
0
    def test_find_empty(self):
        x = XQuery('<R><a>1</a><a>2</a><b>3</b></R>')

        self.assertEquals([], x.find('c'))
Esempio n. 9
0
    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)
Esempio n. 10
0
    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)
Esempio n. 11
0
    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())
Esempio n. 12
0
    def test_clone(self):
        x = XQuery('<R/>')
        y = x.clone()

        self.assertTrue(x == y and id(x) != id(y))
Esempio n. 13
0
    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)
Esempio n. 14
0
    def test_append(self):
        x = XQuery('<R><a>1</a></R>')

        self.assertEquals(XQuery('<R><a>1</a><b>2</b></R>'),
                          x.append(XQuery('<b>2</b>')))
Esempio n. 15
0
    def test_remove_nothing(self):
        x = XQuery('<R><a>1</a><b><c>3</c></b></R>')

        x.remove('d')
        self.assertEquals(XQuery('<R><a>1</a><b><c>3</c></b></R>'),
                          x)
Esempio n. 16
0
    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())
Esempio n. 17
0
    def test_remove_multi(self):
        x = XQuery('''<R><a>1</a><b><c>3</c></b><c>4</c></R>''')

        self.assertEquals(2, len(x.remove('c')))
        self.assertEquals(XQuery('<R><a>1</a><b></b></R>'),
                          x)
Esempio n. 18
0
    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)
Esempio n. 19
0
    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())
Esempio n. 20
0
    def test_find(self):
        x = XQuery('''<R><a>1</a><b>2</b></R>''')

        self.assertEquals(XQuery('<a>1</a>'),
                          x.find('a'))
Esempio n. 21
0
    def test_find_not_exists(self):
        x = XQuery('<R/>')

        self.assertEquals([], x.find('a'))