[Zope3-checkins] CVS: Zope3/src/zope/app/dav/tests - test_propfind.py:1.3.2.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:23:59 -0400
Update of /cvs-repository/Zope3/src/zope/app/dav/tests
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/app/dav/tests
Modified Files:
Tag: cw-mail-branch
test_propfind.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/app/dav/tests/test_propfind.py 1.3 => 1.3.2.1 ===
--- Zope3/src/zope/app/dav/tests/test_propfind.py:1.3 Wed May 21 16:29:46 2003
+++ Zope3/src/zope/app/dav/tests/test_propfind.py Sun Jun 22 10:22:59 2003
@@ -19,14 +19,12 @@
from datetime import datetime
from unittest import TestCase, TestSuite, main, makeSuite
from StringIO import StringIO
-from zope.interface import Interface
from zope.component import getService, getView, getAdapter
from zope.app.services.servicenames import Adapters, Views
from zope.app.traversing import traverse
from zope.publisher.browser import TestRequest
from zope.app.interfaces.file import IWriteFile
from zope.app.interfaces.content.zpt import IZPTPage
-from zope.app.tests.placelesssetup import PlacelessSetup
from zope.app.services.tests.placefulsetup import PlacefulSetup
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.publisher.interfaces.http import IHTTPPresentation
@@ -34,19 +32,20 @@
from zope.pagetemplate.tests.util import normalize_xml
from zope.schema import getFieldNamesInOrder
from zope.app.interfaces.container import IReadContainer
-from zope.schema.interfaces import IText, ITextLine, IDatetime
+from zope.schema.interfaces import IText, ITextLine, IDatetime, ISequence
from zope.app.dav import propfind
-from zope.app.interfaces.dav import IDAVSource, IDAVSchema
-from zope.app.dav.widget import SimpleDAVWidget
+from zope.app.interfaces.dav import IDAVSchema
+from zope.app.dav.widget import TextDAVWidget, SequenceDAVWidget
from zope.app.dav.globaldavschemaservice import provideInterface
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
from zope.app.interfaces.annotation import IAnnotatable, IAnnotations
from zope.app.attributeannotations import AttributeAnnotations
+from zope.interface import implements
class Folder:
- __implements__ = IReadContainer
+ implements(IReadContainer)
def __init__(self, name, level=0):
self.name = name
@@ -63,7 +62,7 @@
class File:
- __implements__ = IWriteFile
+ implements(IWriteFile)
def __init__(self, name, content_type, data):
self.name = name
@@ -75,7 +74,7 @@
class FooZPT:
- __implements__ = (IAnnotatable, IZPTPage)
+ implements(IAnnotatable, IZPTPage)
def getSource(self):
return 'bla bla bla'
@@ -83,7 +82,7 @@
def _createRequest(body=None, headers=None, skip_headers=None):
if body is None:
- body = '''<?xml version="1.0" encoding="utf-8" ?>
+ body = '''<?xml version="1.0" ?>
<propfind xmlns="DAV:">
<prop xmlns:R="http://www.foo.bar/boxschema/">
@@ -132,14 +131,17 @@
provideView(None, 'PROPFIND', IHTTPPresentation,
[propfind.PROPFIND])
provideView(IText, 'view', IBrowserPresentation,
- [SimpleDAVWidget])
+ [TextDAVWidget])
provideView(ITextLine, 'view', IBrowserPresentation,
- [SimpleDAVWidget])
+ [TextDAVWidget])
provideView(IDatetime, 'view', IBrowserPresentation,
- [SimpleDAVWidget])
+ [TextDAVWidget])
+ provideView(ISequence, 'view', IBrowserPresentation,
+ [SequenceDAVWidget])
setDefaultView(IText, IBrowserPresentation, 'view')
setDefaultView(ITextLine, IBrowserPresentation, 'view')
setDefaultView(IDatetime, IBrowserPresentation, 'view')
+ setDefaultView(ISequence, IBrowserPresentation, 'view')
provideAdapter = getService(None, Adapters).provideAdapter
provideAdapter(IAnnotatable, IAnnotations, AttributeAnnotations)
provideAdapter(IAnnotatable, IZopeDublinCore, ZDCAnnotatableAdapter)
@@ -241,7 +243,7 @@
zpt = traverse(root, 'zpt')
dc = getAdapter(zpt, IZopeDublinCore)
dc.title = u'Test Title'
- body = '''<?xml version="1.0" encoding="utf-8"?>
+ body = '''<?xml version="1.0" ?>
<propfind xmlns="DAV:">
<prop xmlns:DC="http://www.purl.org/dc/1.1">
<DC:title />
@@ -254,7 +256,7 @@
'Depth':'0'})
resource_url = str(getView(zpt, 'absolute_url', request))
- expect = '''<?xml version="1.0" encoding="utf-8"?>
+ expect = '''<?xml version="1.0" ?>
<multistatus xmlns="DAV:">
<response>
<href>%(resource_url)s</href>
@@ -282,7 +284,7 @@
zpt = traverse(root, 'zpt')
dc = getAdapter(zpt, IZopeDublinCore)
dc.created = datetime.utcnow()
- body = '''<?xml version="1.0" encoding="utf-8"?>
+ body = '''<?xml version="1.0" ?>
<propfind xmlns="DAV:">
<prop xmlns:DC="http://www.purl.org/dc/1.1">
<DC:created />
@@ -295,7 +297,7 @@
'Depth':'0'})
resource_url = str(getView(zpt, 'absolute_url', request))
- expect = '''<?xml version="1.0" encoding="utf-8"?>
+ expect = '''<?xml version="1.0" ?>
<multistatus xmlns="DAV:">
<response>
<href>%(resource_url)s</href>
@@ -319,10 +321,52 @@
s2 = normalize_xml(expect)
self.assertEqual(s1, s2)
+ def test_davpropdcsubjects(self):
+ root = self.rootFolder
+ zpt = traverse(root, 'zpt')
+ dc = getAdapter(zpt, IZopeDublinCore)
+ dc.subjects = (u'Bla', u'Ble', u'Bli')
+ body = '''<?xml version="1.0" ?>
+ <propfind xmlns="DAV:">
+ <prop xmlns:DC="http://www.purl.org/dc/1.1">
+ <DC:subjects />
+ </prop>
+ </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" ?>
+ <multistatus xmlns="DAV:">
+ <response>
+ <href>%(resource_url)s</href>
+ <propstat>
+ <prop xmlns:a0="http://www.purl.org/dc/1.1">
+ <subjects xmlns="a0">%(subjects)s</subjects>
+ </prop>
+ <status>HTTP/1.1 200 OK</status>
+ </propstat>
+ </response>
+ </multistatus>
+ ''' % {'resource_url':resource_url,
+ 'subjects': u', '.join(dc.subjects) }
+
+ 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_davpropname(self):
root = self.rootFolder
zpt = traverse(root, 'zpt')
- body = '''<?xml version="1.0" encoding="utf-8"?>
+ body = '''<?xml version="1.0" ?>
<propfind xmlns="DAV:">
<propname/>
</propfind>
@@ -340,7 +384,7 @@
props = getFieldNamesInOrder(IDAVSchema)
for p in props:
props_xml += '<%s/>' % p
- expect = '''<?xml version="1.0" encoding="utf-8"?>
+ expect = '''<?xml version="1.0" ?>
<multistatus xmlns="DAV:">
<response>
<href>%(resource_url)s</href>
@@ -367,7 +411,7 @@
def test_davpropnamefolderdepth0(self):
root = self.rootFolder
folder = traverse(root, 'folder')
- body = '''<?xml version="1.0" encoding="utf-8"?>
+ body = '''<?xml version="1.0" ?>
<propfind xmlns="DAV:">
<propname/>
</propfind>
@@ -385,7 +429,7 @@
props = getFieldNamesInOrder(IDAVSchema)
for p in props:
props_xml += '<%s/>' % p
- expect = '''<?xml version="1.0" encoding="utf-8"?>
+ expect = '''<?xml version="1.0" ?>
<multistatus xmlns="DAV:">
<response>
<href>%(resource_url)s</href>
@@ -413,7 +457,7 @@
def test_davpropnamefolderdepth1(self):
root = self.rootFolder
folder = traverse(root, 'folder')
- body = '''<?xml version="1.0" encoding="utf-8"?>
+ body = '''<?xml version="1.0" ?>
<propfind xmlns="DAV:">
<propname/>
</propfind>
@@ -431,7 +475,7 @@
props = getFieldNamesInOrder(IDAVSchema)
for p in props:
props_xml += '<%s/>' % p
- expect = '''<?xml version="1.0" encoding="utf-8"?>
+ expect = '''<?xml version="1.0" ?>
<multistatus xmlns="DAV:">
<response>
<href>%(resource_url)s</href>
@@ -459,7 +503,7 @@
def test_davpropnamefolderdepthinfinity(self):
root = self.rootFolder
folder = traverse(root, 'folder')
- body = '''<?xml version="1.0" encoding="utf-8"?>
+ body = '''<?xml version="1.0" ?>
<propfind xmlns="DAV:">
<propname/>
</propfind>
@@ -477,7 +521,7 @@
props = getFieldNamesInOrder(IDAVSchema)
for p in props:
props_xml += '<%s/>' % p
- expect = '''<?xml version="1.0" encoding="utf-8"?>
+ expect = '''<?xml version="1.0" ?>
<multistatus xmlns="DAV:">
<response>
<href>%(resource_url)s</href>