[Zope-CVS] CVS: Packages/Moztop/moztopsupport/dav/tests - test_propfind.py:1.4

Sidnei da Silva sidnei@x3ng.com.br
Tue, 25 Mar 2003 16:16:02 -0500


Update of /cvs-repository/Packages/Moztop/moztopsupport/dav/tests
In directory cvs.zope.org:/tmp/cvs-serv1216/moztopsupport/dav/tests

Modified Files:
	test_propfind.py 
Log Message:
small cleanup. should work a little better now~

=== Packages/Moztop/moztopsupport/dav/tests/test_propfind.py 1.3 => 1.4 ===
--- Packages/Moztop/moztopsupport/dav/tests/test_propfind.py:1.3	Mon Mar 24 11:15:37 2003
+++ Packages/Moztop/moztopsupport/dav/tests/test_propfind.py	Tue Mar 25 16:16:01 2003
@@ -29,10 +29,12 @@
 from zope.app.services.tests.placefulsetup import PlacefulSetup
 from zope.publisher.interfaces.browser import IBrowserPresentation
 from zope.app.browser.absoluteurl import AbsoluteURL
+from zope.pagetemplate.tests.util import normalize_xml
+from zope.schema import getFieldNamesInOrder
 
 from moztopsupport.dav import propfind 
 from moztopsupport.dav.views import ZPTDAVSource
-from moztopsupport.dav.interfaces import IDAVSource
+from moztopsupport.dav.interfaces import IDAVSource, IDAVSchema
 
 class File:
 
@@ -79,13 +81,6 @@
     request.setViewType(IBrowserPresentation)
     return request
 
-def prettyXML(src):
-    from xml.dom import minidom
-    src = minidom.parseString(src)
-
-    return src.toxml()
-    
-
 class TestPlacefulPROPFIND(PlacefulSetup, TestCase):
 
     def setUp(self):
@@ -227,7 +222,52 @@
         # Check HTTP Response
         self.assertEqual(request.response.getStatus(), 207)
         self.assertEqual(pfind.getDepth(), '0')
-        self.assertEqual(prettyXML(request.response._body), prettyXML(expect))
+        s1 = normalize_xml(request.response._body)
+        s2 = normalize_xml(expect)
+        self.assertEqual(s1, s2)
+
+    def test_davpropname(self):
+        root = self.rootFolder
+        zpt = traverse(root, 'zpt')
+        body = '''<?xml version="1.0" encoding="utf-8" ?>
+        <propfind xmlns="DAV:">
+        <propname/>
+        </propfind>
+        '''
+
+        request = _createRequest(body=body,
+                                 headers={'Content-type':'text/xml',
+                                          'Depth':'0'})
+
+        resource_url = str(getView(zpt, 'absolute_url', request))
+        props = getFieldNamesInOrder(IDAVSchema)
+        props_xml = ''
+        for p in props:
+            props_xml += '<D:%s />' % p
+        expect = '''<?xml version="1.0" encoding="utf-8" ?>
+        <D:multistatus xmlns:D="DAV:">
+        <D:response>
+        <D:href>%(resource_url)s</D:href>
+        <D:propstat>
+        <D:prop>
+        %(props_xml)s
+        </D:prop>
+        <D:status>HTTP/1.1 200 OK</D:status>
+        </D:propstat>
+        </D:response>
+        </D:multistatus>
+        ''' % {'resource_url':resource_url,
+               'props_xml':props_xml}
+
+        pfind = propfind.PROPFIND(zpt, request)
+
+        pfind.PROPFIND()
+        # Check HTTP Response
+        self.assertEqual(request.response.getStatus(), 207)
+        self.assertEqual(pfind.getDepth(), '0')
+        s1 = normalize_xml(request.response._body)
+        s2 = normalize_xml(expect)
+        self.assertEqual(s1, s2)
 
 def test_suite():
     return TestSuite((