[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/file/fssync/ fix
missing import reported on zope3-dev; added tests
Fred L. Drake, Jr.
fdrake at gmail.com
Mon Mar 28 12:11:19 EST 2005
Log message for revision 29695:
fix missing import reported on zope3-dev; added tests
http://mail.zope.org/pipermail/zope3-dev/2005-March/013885.html
Changed:
U Zope3/trunk/src/zope/app/file/fssync/adapter.py
A Zope3/trunk/src/zope/app/file/fssync/tests.py
-=-
Modified: Zope3/trunk/src/zope/app/file/fssync/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/file/fssync/adapter.py 2005-03-28 16:34:11 UTC (rev 29694)
+++ Zope3/trunk/src/zope/app/file/fssync/adapter.py 2005-03-28 17:11:17 UTC (rev 29695)
@@ -18,7 +18,7 @@
__docformat__ = 'restructuredtext'
from zope.interface import implements
-from zope.fssync.server.entryadapter import ObjectEntryAdapter
+from zope.fssync.server.entryadapter import ObjectEntryAdapter, AttrMapping
from zope.fssync.server.interfaces import IObjectFile
class FileAdapter(ObjectEntryAdapter):
Added: Zope3/trunk/src/zope/app/file/fssync/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/file/fssync/tests.py 2005-03-28 16:34:11 UTC (rev 29694)
+++ Zope3/trunk/src/zope/app/file/fssync/tests.py 2005-03-28 17:11:17 UTC (rev 29695)
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Unit tests for the zope.app.file.file.File fssync adapter.
+
+"""
+__docformat__ = "reStructuredText"
+
+import unittest
+
+import zope.app.file.fssync.adapter
+
+
+class FauxFile:
+
+ def __init__(self, data, contentType=None):
+ self.data = data
+ self.contentType = contentType
+
+
+class FileAdapterTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.ob = FauxFile("test data", "text/plain")
+ self.adapter = zope.app.file.fssync.adapter.FileAdapter(self.ob)
+
+ def test_extra(self):
+ extra = self.adapter.extra()
+ self.assertEqual(extra["contentType"], "text/plain")
+ extra["contentType"] = "text/x-foo"
+ self.assertEqual(extra["contentType"], "text/x-foo")
+ self.assertEqual(self.ob.contentType, "text/x-foo")
+ self.ob.contentType = "text/x-bar"
+ self.assertEqual(extra["contentType"], "text/x-bar")
+
+ def test_getBody(self):
+ self.assertEqual(self.adapter.getBody(), "test data")
+ self.ob.data = "other data"
+ self.assertEqual(self.adapter.getBody(), "other data")
+
+ def test_setBody(self):
+ self.adapter.setBody("more text")
+ self.assertEqual(self.ob.data, "more text")
+ self.assertEqual(self.adapter.getBody(), "more text")
+
+
+def test_suite():
+ return unittest.makeSuite(FileAdapterTestCase)
Property changes on: Zope3/trunk/src/zope/app/file/fssync/tests.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
More information about the Zope3-Checkins
mailing list