From: <svn...@pl...> - 2004-07-25 18:35:21
|
Author: shh42 Date: Sun Jul 25 13:47:21 2004 New Revision: 5504 Modified: CMFPlone/branches/Plone-2_0-branch/tests/testWebDAV.py Log: Add a test to confirm the fix for http://plone.org/collector/3217 The fix itself is in CMFDefault.Document, not Plone. Modified: CMFPlone/branches/Plone-2_0-branch/tests/testWebDAV.py ============================================================================== --- CMFPlone/branches/Plone-2_0-branch/tests/testWebDAV.py (original) +++ CMFPlone/branches/Plone-2_0-branch/tests/testWebDAV.py Sun Jul 25 13:47:21 2004 @@ -6,7 +6,12 @@ from Products.CMFPlone.tests import PloneTestCase from Products.CMFCore.utils import getToolByName -# Python 2.1 compatibility +from webdav.NullResource import NullResource +from Acquisition import aq_base + +import base64 +auth_info = 'Basic %s' % base64.encodestring('%s:secret' % PloneTestCase.default_user) + def mkdict(items): '''Constructs a dict from a sequence of (key, value) pairs.''' d = {} @@ -27,10 +32,51 @@ self.assertEquals(items['title'], self.portal.title) +class TestDAVMetadata(PloneTestCase.PloneTestCase): + # Confirms fix for http://plone.org/collector/3217 + # The fix itself is in CMFDefault.Document, not Plone. + + html = """\ +<html> +<head><title>Foo</title></head> +<body>Bar</body> +</html> +""" + + def afterSetUp(self): + request = self.app.REQUEST + request['PARENTS'] = [self.app] + # Fake a PUT request + request['BODY'] = self.html + request.environ['CONTENT_TYPE'] = 'text/html' + request.environ['REQUEST_METHOD'] = 'PUT' + request._auth = auth_info + request.RESPONSE._auth = 1 + request.maybe_webdav_client = 1 + # PUT a document + new = NullResource(self.folder, 'doc', request).__of__(self.folder) + new.PUT(request, request.RESPONSE) + + def testDocumentMetadata(self): + doc = self.folder.doc + self.assertEqual(doc.Title(), 'Foo') + self.assertEqual(doc.EditableBody(), 'Bar') + self.assertEqual(doc.Format(), 'text/html') + # Remaining elements should contain the defaults + self.assertEqual(doc.Description(), '') + self.assertEqual(doc.Subject(), ()) + self.assertEqual(doc.Contributors(), ()) + self.assertEqual(doc.EffectiveDate(), 'None') + self.assertEqual(doc.ExpirationDate(), 'None') + self.assertEqual(doc.Language(), '') + self.assertEqual(doc.Rights(), '') + + def test_suite(): from unittest import TestSuite, makeSuite suite = TestSuite() suite.addTest(makeSuite(TestDAVProperties)) + suite.addTest(makeSuite(TestDAVMetadata)) return suite if __name__ == '__main__': |