コード例 #1
0
 def test_attributeWithValueAny(self):
     """
     Test find nodes with attribute having value.
     """
     xp = XPathQuery("/foo/*[@attrib2='value2']")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar2])
コード例 #2
0
 def test_orOperator(self):
     """
     Test boolean or operator in condition.
     """
     xp = XPathQuery("//bar[@attrib5='value4' or @attrib5='value5']")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar5, self.bar6])
コード例 #3
0
 def test_position(self):
     """
     Test finding element at position.
     """
     xp = XPathQuery("/foo/bar[2]")
     self.assertEquals(xp.matches(self.e), 1)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar1])
コード例 #4
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_position(self):
     """
     Test finding element at position.
     """
     xp = XPathQuery("/foo/bar[2]")
     self.assertEquals(xp.matches(self.e), 1)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar1])
コード例 #5
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_attributeWithValueAny(self):
     """
     Test find nodes with attribute having value.
     """
     xp = XPathQuery("/foo/*[@attrib2='value2']")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar2])
コード例 #6
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_orOperator(self):
     """
     Test boolean or operator in condition.
     """
     xp = XPathQuery("//bar[@attrib5='value4' or @attrib5='value5']")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar5, self.bar6])
コード例 #7
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_booleanOperatorsParens(self):
     """
     Test multiple boolean operators in condition with parens.
     """
     xp = XPathQuery("""//bar[@attrib4='value4' and
                              (@attrib5='value4' or @attrib5='value6')]""")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar6, self.bar7])
コード例 #8
0
 def test_locationFooBarFoo(self):
     """
     Test finding foos at the second level.
     """
     xp = XPathQuery("/foo/bar/foo")
     self.assertEquals(xp.matches(self.e), 1)
     self.assertEquals(xp.queryForNodes(self.e),
                       [self.subfoo, self.subfoo3, self.subfoo4])
コード例 #9
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_queryForNodes(self):
     """
     Test finding nodes.
     """
     xp = XPathQuery("/foo/bar")
     self.assertEquals(xp.queryForNodes(self.e), [self.bar1, self.bar2,
                                                  self.bar4, self.bar5,
                                                  self.bar6, self.bar7])
コード例 #10
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_queryForString(self):
     """
     Test for queryForString and queryForStringList.
     """
     xp = XPathQuery("/foo")
     self.assertEquals(xp.queryForString(self.e), "somecontent")
     self.assertEquals(xp.queryForStringList(self.e),
                       ["somecontent", "somemorecontent"])
コード例 #11
0
 def test_queryForString(self):
     """
     Test for queryForString and queryForStringList.
     """
     xp = XPathQuery("/foo")
     self.assertEquals(xp.queryForString(self.e), "somecontent")
     self.assertEquals(xp.queryForStringList(self.e),
                       ["somecontent", "somemorecontent"])
コード例 #12
0
 def test_queryForNodes(self):
     """
     Test finding nodes.
     """
     xp = XPathQuery("/foo/bar")
     self.assertEquals(
         xp.queryForNodes(self.e),
         [self.bar1, self.bar2, self.bar4, self.bar5, self.bar6, self.bar7])
コード例 #13
0
 def test_booleanOperatorsParens(self):
     """
     Test multiple boolean operators in condition with parens.
     """
     xp = XPathQuery("""//bar[@attrib4='value4' and
                              (@attrib5='value4' or @attrib5='value6')]""")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar6, self.bar7])
コード例 #14
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_locationFooBarFoo(self):
     """
     Test finding foos at the second level.
     """
     xp = XPathQuery("/foo/bar/foo")
     self.assertEquals(xp.matches(self.e), 1)
     self.assertEquals(xp.queryForNodes(self.e), [self.subfoo,
                                                  self.subfoo3,
                                                  self.subfoo4])
コード例 #15
0
 def test_locationAllChilds(self):
     """
     Test finding childs of foo.
     """
     xp = XPathQuery("/foo/*")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(
         xp.queryForNodes(self.e),
         [self.bar1, self.bar2, self.bar4, self.bar5, self.bar6, self.bar7])
コード例 #16
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_locationAllChilds(self):
     """
     Test finding childs of foo.
     """
     xp = XPathQuery("/foo/*")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar1, self.bar2,
                                                  self.bar4, self.bar5,
                                                  self.bar6, self.bar7])
コード例 #17
0
 def test_anyLocation(self):
     """
     Test finding any nodes named bar.
     """
     xp = XPathQuery("//bar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [
         self.bar1, self.bar2, self.bar3, self.bar4, self.bar5, self.bar6,
         self.bar7
     ])
コード例 #18
0
 def test_anyLocationAndText(self):
     """
     Test finding any nodes named gar and getting their text contents.
     """
     xp = XPathQuery("//gar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e),
                       [self.gar1, self.gar2, self.gar3, self.gar4])
     self.assertEquals(xp.queryForStringList(self.e),
                       ["DEF", "ABC", "JKL", "MNO"])
コード例 #19
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_anyLocationAndText(self):
     """
     Test finding any nodes named gar and getting their text contents.
     """
     xp = XPathQuery("//gar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.gar1, self.gar2,
                                                  self.gar3, self.gar4])
     self.assertEquals(xp.queryForStringList(self.e), ["DEF", "ABC",
                                                       "JKL", "MNO"])
コード例 #20
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_anyLocation(self):
     """
     Test finding any nodes named bar.
     """
     xp = XPathQuery("//bar")
     self.assertEquals(xp.matches(self.e), True)
     self.assertEquals(xp.queryForNodes(self.e), [self.bar1, self.bar2,
                                                  self.bar3, self.bar4,
                                                  self.bar5, self.bar6,
                                                  self.bar7])
コード例 #21
0
 def test_anyLocationQueryForString(self):
     """
     L{XPathQuery.queryForString} should raise a L{NotImplementedError}
     for any location.
     """
     xp = XPathQuery("//bar")
     self.assertRaises(NotImplementedError, xp.queryForString, None)
コード例 #22
0
 def test_textNotOperator(self):
     """
     Test for not operator.
     """
     xp = XPathQuery("/foo[not(@nosuchattrib)]")
     self.assertEquals(xp.matches(self.e), True)
コード例 #23
0
 def test_textCondition(self):
     """
     Test matching a node with given text.
     """
     xp = XPathQuery("/foo[text() = 'somecontent']")
     self.assertEquals(xp.matches(self.e), True)
コード例 #24
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_namespaceNotFound(self):
     """
     Test not matching node with wrong namespace.
     """
     xp = XPathQuery("/foo[@xmlns='badns']/bar2")
     self.assertEquals(xp.matches(self.e), 0)
コード例 #25
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_locationFooBar(self):
     """
     Test matching foo with child bar.
     """
     xp = XPathQuery("/foo/bar")
     self.assertEquals(xp.matches(self.e), 1)
コード例 #26
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_attribute(self):
     """
     Test matching foo with attribute.
     """
     xp = XPathQuery("/foo[@attrib1]")
     self.assertEquals(xp.matches(self.e), True)
コード例 #27
0
 def test_namespaceNotFound(self):
     """
     Test not matching node with wrong namespace.
     """
     xp = XPathQuery("/foo[@xmlns='badns']/bar2")
     self.assertEquals(xp.matches(self.e), 0)
コード例 #28
0
 def test_namespaceFound(self):
     """
     Test matching node with namespace.
     """
     xp = XPathQuery("/foo[@xmlns='testns']/bar")
     self.assertEquals(xp.matches(self.e), 1)
コード例 #29
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_textCondition(self):
     """
     Test matching a node with given text.
     """
     xp = XPathQuery("/foo[text() = 'somecontent']")
     self.assertEquals(xp.matches(self.e), True)
コード例 #30
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_textNotOperator(self):
     """
     Test for not operator.
     """
     xp = XPathQuery("/foo[not(@nosuchattrib)]")
     self.assertEquals(xp.matches(self.e), True)
コード例 #31
0
 def test_attribute(self):
     """
     Test matching foo with attribute.
     """
     xp = XPathQuery("/foo[@attrib1]")
     self.assertEquals(xp.matches(self.e), True)
コード例 #32
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_namespaceFound(self):
     """
     Test matching node with namespace.
     """
     xp = XPathQuery("/foo[@xmlns='testns']/bar")
     self.assertEquals(xp.matches(self.e), 1)
コード例 #33
0
 def test_attributeWithValue(self):
     """
     Test matching node with attribute having value.
     """
     xp = XPathQuery("/foo[@attrib1='value1']")
     self.assertEquals(xp.matches(self.e), 1)
コード例 #34
0
 def test_locationFooBar(self):
     """
     Test matching foo with child bar.
     """
     xp = XPathQuery("/foo/bar")
     self.assertEquals(xp.matches(self.e), 1)
コード例 #35
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_attributeWithValue(self):
     """
     Test matching node with attribute having value.
     """
     xp = XPathQuery("/foo[@attrib1='value1']")
     self.assertEquals(xp.matches(self.e), 1)
コード例 #36
0
 def test_locationNoBar3(self):
     """
     Test not finding bar3.
     """
     xp = XPathQuery("/foo/bar3")
     self.assertEquals(xp.matches(self.e), 0)
コード例 #37
0
ファイル: test_xpath.py プロジェクト: Hetal728/SMP-ClassiCube
 def test_locationNoBar3(self):
     """
     Test not finding bar3.
     """
     xp = XPathQuery("/foo/bar3")
     self.assertEquals(xp.matches(self.e), 0)