[Zope-CVS] CVS: Packages/Moztop/moztopsupport/dav/tests - test_propfind.py:1.3
Sidnei da Silva
sidnei@x3ng.com.br
Mon, 24 Mar 2003 11:15:38 -0500
Update of /cvs-repository/Packages/Moztop/moztopsupport/dav/tests
In directory cvs.zope.org:/tmp/cvs-serv30759/dav/tests
Modified Files:
test_propfind.py
Log Message:
Ops, fixed some typoes. Need a better way to compare XML response.
=== Packages/Moztop/moztopsupport/dav/tests/test_propfind.py 1.2 => 1.3 ===
--- Packages/Moztop/moztopsupport/dav/tests/test_propfind.py:1.2 Mon Mar 24 10:38:23 2003
+++ Packages/Moztop/moztopsupport/dav/tests/test_propfind.py Mon Mar 24 11:15:37 2003
@@ -19,7 +19,7 @@
from unittest import TestCase, TestSuite, main, makeSuite
from StringIO import StringIO
from zope.interface import Interface
-from zope.component import getService
+from zope.component import getService, getView
from zope.app.services.servicenames import Adapters, Views
from zope.app.traversing import traverse
from zope.publisher.browser import TestRequest
@@ -79,6 +79,13 @@
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):
@@ -188,16 +195,23 @@
</D:prop>
</D:propfind>
'''
+
+ request = _createRequest(body=body,
+ headers={'Content-type':'text/xml',
+ 'Depth':'0'})
+
+ resource_url = str(getView(zpt, 'absolute_url', request))
+
expect = '''<?xml version="1.0" encoding="utf-8" ?>
<D:multistatus xmlns:D="DAV:">
<D:response>
- <D:href>http://localhost:9080/zpt/</D:href>
+ <D:href>%(resource_url)s</D:href>
<D:propstat>
<D:prop>
<D:source>
<D:link>
- <D:src>http://localhost:9080/zpt</D:src>
- <D:dst>http://localhost:9080/zpt/getSource</D:dst>
+ <D:src>%(resource_url)s</D:src>
+ <D:dst>%(resource_url)s/getSource</D:dst>
</D:link>
</D:source>
</D:prop>
@@ -205,11 +219,7 @@
</D:propstat>
</D:response>
</D:multistatus>
- '''
-
- request = _createRequest(body=body,
- headers={'Content-type':'text/xml',
- 'Depth':'0'})
+ ''' % {'resource_url':resource_url}
pfind = propfind.PROPFIND(zpt, request)
@@ -217,8 +227,7 @@
# Check HTTP Response
self.assertEqual(request.response.getStatus(), 207)
self.assertEqual(pfind.getDepth(), '0')
- print request.response._body
- self.assertEqual(request.response._body, expect)
+ self.assertEqual(prettyXML(request.response._body), prettyXML(expect))
def test_suite():
return TestSuite((