Example #1
0
    def test_toString_NoChangesMade_ReturnOriginalXml(self):

        xml = Xml('<some>xml</some>')

        result = xml.toString()

        self.assertEqual('<some>xml</some>', result)
Example #2
0
    def test_getFirstNodeText_XPathNodeExists_ReturnNodeContents(self):

        xml = Xml('<stuff><things>words words</things></stuff>')

        result = xml.getFirstNodeText('.//things')

        self.assertEqual('words words', result)
Example #3
0
    def test_getFirstNodeText_XPathNodeDoesNotExist_ReturnNone(self):

        xml = Xml('<stuff><things>words words</things></stuff>')

        result = xml.getFirstNodeText('.//friday')

        self.assertEqual(None, result)
Example #4
0
    def test_setFirstNodeText_XPathNodeExists_ReturnTrue(self):

        xml = Xml('<element><other>text</other></element>')

        result = xml.setFirstNodeText('.//other', 'whatever')

        self.assertEqual(True, result)
Example #5
0
    def test_setFirstNodeText_XPathNodeDoesNotExist_ReturnFalse(self):

        xml = Xml('<element><other>text</other></element>')

        result = xml.setFirstNodeText('.//pies', 'whatever')

        self.assertEqual(False, result)
Example #6
0
    def test_toString_XmlHeaderAndSetFirstNodeTextReturnsTrue_XmlHeaderRemoved(self):

        xml = Xml("<?xml version='1.0' encoding='UTF-8'?>\n<element><other>text</other></element>")

        xml.setFirstNodeText('.//other', 'pies')

        result = xml.toString()

        self.assertEqual('<element><other>pies</other></element>', result)
Example #7
0
    def test_toString_setFirstNodeTextReturnsFalse_ReturnOriginalXml(self):

        xml = Xml('<element><other>text</other></element>')

        xml.setFirstNodeText('.//notfound', 'whatever')

        result = xml.toString()

        self.assertEqual('<element><other>text</other></element>', result)
Example #8
0
    def test_toString_setFirstNodeTextReturnsTrue_ReturnModifiedXml(self):

        xml = Xml('<element><other>text</other></element>')

        xml.setFirstNodeText('.//other', 'pies')

        result = xml.toString()

        self.assertEqual('<element><other>pies</other></element>', result)
Example #9
0
    def create(self, rawXml):

        return Configuration(Xml(rawXml))