[4suite-checkins] In Amara/test/bindery, files mutation.py, realworld.py

Uche Ogbuji uogbuji at 4suite.org
Fri Dec 15 00:44:30 MST 2006


Modified Files:
    mutation.py realworld.py

Log Message:
Fix bug with mutation using mapping access
Beef up manual sections on XML/Python name mismatches

ViewCVS diff:
  http://cvs.4suite.org/viewcvs/Amara/test/bindery/mutation.py.diff?r1=1.21&r2=1.22
ViewCVS view:
  http://cvs.4suite.org/viewcvs/Amara/test/bindery/mutation.py?rev=1.22&content-type=text/vnd.viewcvs-markup

Index: mutation.py
===================================================================
RCS file: /var/local/cvsroot/Amara/test/bindery/mutation.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -U2 -r1.21 -r1.22
--- mutation.py	26 Nov 2006 07:29:07 -0000	1.21
+++ mutation.py	15 Dec 2006 07:44:30 -0000	1.22
@@ -7,4 +7,5 @@
 from Ft.Xml.Xslt.XmlWriter import XmlWriter
 from Ft.Xml.Xslt.OutputParameters import OutputParameters
+from xml.dom import Node
 
 
@@ -377,4 +378,23 @@
         return
 
+    def testDelChildElementWithClash1(self):
+        DOC = '<a-1 b-1=""><b-1/></a-1>'
+        EXPECTED = '<a-1 b-1=""/>'
+        doc = amara.parse(DOC)
+        E = Node.ELEMENT_NODE
+        del doc[E, None, u'a-1'][E, None, u'b-1']
+        self.assertEqual(doc.xml(), XMLDECL+EXPECTED)
+        return
+
+    def testDelAttributeWithClash1(self):
+        DOC = '<a-1 b-1=""><b-1/></a-1>'
+        EXPECTED = '<a-1><b-1/></a-1>'
+        doc = amara.parse(DOC)
+        E = Node.ELEMENT_NODE
+        A = Node.ATTRIBUTE_NODE
+        del doc[E, None, u'a-1'][A, None, u'b-1']
+        self.assertEqual(doc.xml(), XMLDECL+EXPECTED)
+        return
+
     def testDelAttribute1(self):
         DOC = '<a b="spam"><b>spam</b></a>'
ViewCVS diff:
  http://cvs.4suite.org/viewcvs/Amara/test/bindery/realworld.py.diff?r1=1.16&r2=1.17
ViewCVS view:
  http://cvs.4suite.org/viewcvs/Amara/test/bindery/realworld.py?rev=1.17&content-type=text/vnd.viewcvs-markup

Index: realworld.py
===================================================================
RCS file: /var/local/cvsroot/Amara/test/bindery/realworld.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -U2 -r1.16 -r1.17
--- realworld.py	16 Jun 2006 14:07:36 -0000	1.16
+++ realworld.py	15 Dec 2006 07:44:30 -0000	1.17
@@ -604,4 +604,34 @@
 
 
+ANS = u'http://www.w3.org/2005/Atom'
+XNS = u'http://www.w3.org/1999/xhtml'
+
+class TestElarson061209(TestBase):
+    #Eric Larson was having trouble creating Atom entries with XHTML
+    id = u'urn:x-bogus:1'
+    updated = u'2006-12-10T02:40:45.343000Z'
+    title = u'XSL is Fun'
+    expected = """<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns="http://www.w3.org/2005/Atom"><id>urn:x-bogus:1</id><title>XSL is Fun</title><updated>2006-12-10T02:40:45.343000Z</updated><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
+      <div class="document" id="xsl-is-fun">
+        <p>The past couple months have been a lot of fun. I have been working with my blog, which has become focused around XML.</p></div>
+    </div></content></entry>"""
+    
+    def testCreateAtom1(self):
+        content = '\n      <div class="document" id="xsl-is-fun">\n        <p>The past couple months have been a lot of fun. I have been working with my blog, which has become focused around XML.</p></div>\n    '
+        e = amara.create_document()
+        e.xml_append(e.xml_create_element(u'entry', ANS))
+        e.entry.xml_append(e.xml_create_element(u'id', ANS, content=self.id))
+        e.entry.xml_append(e.xml_create_element(u'title', ANS, content=self.title))
+        e.entry.xml_append(e.xml_create_element(u'updated', ANS, content=self.updated))
+        e.entry.xml_append(e.xml_create_element(u'content', ANS, attributes={u'type' : u'xhtml'}))
+        e.entry.content.xml_append(e.xml_create_element(u'div', XNS))
+        e.entry.content.div.xml_append_fragment(content)
+        self.assertEqual(e.xml(), self.expected)
+        
+        #e.entry.content.div.div.xmlnsUri = XNS
+        return
+
+
 if __name__ == '__main__':
     unittest.main()


More information about the 4suite-checkins mailing list