[Zope3-checkins] CVS: Zope3/src/zope/app/fssync/tests -
test_committer.py:1.22
Fred L. Drake, Jr.
fred at zope.com
Tue Jan 13 17:29:18 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/fssync/tests
In directory cvs.zope.org:/tmp/cvs-serv16405/src/zope/app/fssync/tests
Modified Files:
test_committer.py
Log Message:
- move the fssync "Syner" and serialization adapter interfaces into
the zope.fssync.server package
- remove annotations() from IObjectEntry, implementations
(should be near-free since these should not used anymore)
- make the syncer, checker, committer parameterizable with three
functions that operate on content objects:
- get the serialization adapter
- get the annotations adapter
- get the object identifier
=== Zope3/src/zope/app/fssync/tests/test_committer.py 1.21 => 1.22 ===
--- Zope3/src/zope/app/fssync/tests/test_committer.py:1.21 Tue Jan 13 14:32:22 2004
+++ Zope3/src/zope/app/fssync/tests/test_committer.py Tue Jan 13 17:28:47 2004
@@ -39,7 +39,7 @@
from zope.app.location import Location
from zope.app.tests.placelesssetup import PlacelessSetup
-from zope.app.fssync import committer # The module
+from zope.app.fssync import committer, syncer # The module
from zope.app.fssync.committer import Checker, Committer, SynchronizationError
from zope.app.fssync.fsregistry import provideSynchronizer, fsRegistry
from zope.app.interfaces.fssync import IGlobalFSSyncService
@@ -150,13 +150,15 @@
return lst
-class TestCommitterModule(TestBase):
+class TestSyncerModule(TestBase):
- def test_get_adapter(self):
+ def test_getSerializer(self):
obj = Sample()
- adapter = committer.get_adapter(obj)
+ adapter = syncer.getSerializer(obj)
self.assertEqual(adapter.__class__, DefaultFileAdpater)
+class TestCommitterModule(TestBase):
+
def test_read_file(self):
data = "12345\rabcde\n12345\r\nabcde"
tfn = self.tempfile(data, "wb")
@@ -184,6 +186,12 @@
self.assertRaises(KeyError, committer.set_item,
container, "foo", 42, replace=True)
+ def create_object(self, *args, **kw):
+ # Helper for the create_object() tests.
+ c = Committer(syncer.getSerializer,
+ getAnnotations=syncer.getAnnotations)
+ c.create_object(*args, **kw)
+
def test_create_object_factory_file(self):
provideSynchronizer(dict, DictAdapter)
container = {}
@@ -191,7 +199,7 @@
tfn = os.path.join(self.tempdir(), "foo")
data = {"hello": "world"}
self.writefile(dumps(data), tfn)
- committer.create_object(container, "foo", entry, tfn)
+ self.create_object(container, "foo", entry, tfn)
self.assertEqual(container, {"foo": data})
def test_create_object_factory_directory(self):
@@ -200,7 +208,7 @@
entry = {"flag": "added", "factory": PCname}
tfn = os.path.join(self.tempdir(), "foo")
os.mkdir(tfn)
- committer.create_object(container, "foo", entry, tfn)
+ self.create_object(container, "foo", entry, tfn)
self.assertEqual(container.keys(), ["foo"])
self.assertEqual(container["foo"].__class__, PretendContainer)
@@ -210,7 +218,7 @@
data = ["hello", "world"]
tfn = os.path.join(self.tempdir(), "foo")
self.writefile(dumps(data), tfn, "wb")
- committer.create_object(container, "foo", entry, tfn)
+ self.create_object(container, "foo", entry, tfn)
self.assertEqual(container.items(), [("foo", ["hello", "world"])])
def test_create_object_ifilefactory(self):
@@ -220,16 +228,17 @@
data = ["hello", "world"]
tfn = os.path.join(self.tempdir(), "foo")
self.writefile(dumps(data), tfn, "wb")
- committer.create_object(container, "foo", entry, tfn)
+ self.create_object(container, "foo", entry, tfn)
self.assertEqual(container.holding, {"foo": ["hello", "world"]})
def test_create_object_idirectoryfactory(self):
- ztapi.provideAdapter(IContainer, IDirectoryFactory, directory_factory_maker)
+ ztapi.provideAdapter(IContainer, IDirectoryFactory,
+ directory_factory_maker)
container = PretendContainer()
entry = {"flag": "added"}
tfn = os.path.join(self.tempdir(), "foo")
os.mkdir(tfn)
- committer.create_object(container, "foo", entry, tfn)
+ self.create_object(container, "foo", entry, tfn)
self.assertEqual(container.holding["foo"].__class__, PretendContainer)
@@ -281,7 +290,8 @@
self.fooentry["path"] = "/parent/child/foo"
# Set up checker
- self.checker = Checker(self.metadata)
+ self.checker = Checker(syncer.getSerializer, self.metadata,
+ getAnnotations=syncer.getAnnotations)
def check_errors(self, expected_errors):
# Helper to call the checker and assert a given set of errors
@@ -504,7 +514,8 @@
def setUp(self):
TestCheckerClass.setUp(self)
- self.committer = Committer(self.metadata)
+ self.committer = Committer(syncer.getSerializer, self.metadata,
+ getAnnotations=syncer.getAnnotations)
def check_no_errors(self):
TestCheckerClass.check_no_errors(self)
@@ -562,6 +573,7 @@
def test_suite():
s = unittest.TestSuite()
+ s.addTest(unittest.makeSuite(TestSyncerModule))
s.addTest(unittest.makeSuite(TestCommitterModule))
s.addTest(unittest.makeSuite(TestCheckerClass))
s.addTest(unittest.makeSuite(TestCommitterClass))
More information about the Zope3-Checkins
mailing list