[Zope3-checkins] CVS: Zope3/src/zope/app/fssync/tests - test_committer.py:1.10

Guido van Rossum guido@python.org
Tue, 3 Jun 2003 13:09:23 -0400


Update of /cvs-repository/Zope3/src/zope/app/fssync/tests
In directory cvs.zope.org:/tmp/cvs-serv20741/zope/app/fssync/tests

Modified Files:
	test_committer.py 
Log Message:
Refactored the Committer class, separating it out (again!) into a
Checker class and a Committer class.  The Committer class no longer
modifies the filesystem; that's toFS()'s responsibility (also due for
a rewrite).  The unit tests for Committer are much more sensible now.


=== Zope3/src/zope/app/fssync/tests/test_committer.py 1.9 => 1.10 === (659/759 lines abridged)
--- Zope3/src/zope/app/fssync/tests/test_committer.py:1.9	Mon Jun  2 15:48:49 2003
+++ Zope3/src/zope/app/fssync/tests/test_committer.py	Tue Jun  3 13:08:53 2003
@@ -36,15 +36,18 @@
 from zope.app.interfaces.fssync import IGlobalFSSyncService
 from zope.app.interfaces.traversing import ITraversable
 
-from zope.app.fssync.committer import Committer, SynchronizationError
+from zope.app.fssync import committer # The module
+from zope.app.fssync.committer import Checker, Committer, SynchronizationError
 from zope.app.fssync.fsregistry import provideSynchronizer, fsRegistry
 from zope.app.fssync.classes import Default
 
 from zope.app.content.fssync import DirectoryAdapter
 
+
 class Sample(object):
     pass
 
+
 class PretendContainer(object):
     
     __implements__ = IContainer, ITraversable, IZopeContainer
@@ -67,10 +70,17 @@
         name = name.lower()
         return self.holding[name]
 
+    def get(self, name):
+        name = name.lower()
+        return self.holding.get(name)
+
     def __contains__(self, name):
         name = name.lower()
         return name in self.holding
 
+    def keys(self):
+        return self.holding.keys()
+
     def items(self):
         return self.holding.items()
 
@@ -82,6 +92,7 @@
 
 PCname = PretendContainer.__module__ + "." + PretendContainer.__name__
 
+
 class DictAdapter(Default):
 
     def setBody(self, body):
@@ -94,7 +105,10 @@
             if key not in new:

[-=- -=- -=- 659 lines omitted -=- -=- -=-]

+        self.assertEqual(self.child["grandchild"], self.grandchild)
+        self.assertEqual(self.grandchild.keys(), [])
+
+    def verify_file_added(self):
+        self.assertEqual(self.child["bar"], self.bar)
+        self.assertEqual(sort(self.child.keys()), ["bar", "foo", "grandchild"])
+
+    def verify_file_changed(self):
+        self.assertEqual(self.child["foo"], self.newfoo)
+    
+    def verify_file_removed(self):
+        self.assertEqual(self.child.keys(), ["grandchild"])
+
+    def verify_file_spurious(self):
+        self.verify_vanilla()
+
+    def verify_file_type_changed(self):
+        self.assertEqual(self.child["foo"], self.newfoo)
+
+    def verify_dir_removed(self):
+        self.assertEqual(self.child.keys(), ["foo"])
+
+    def verify_dir_added(self):
+        self.assertEqual(sort(self.child.keys()), ["bar", "foo", "grandchild"])
+
+    def verify_dir_spurious(self):
+        self.verify_vanilla()
+
+    def verify_tree_added(self):
+        self.assertEqual(sort(self.child.keys()), ["bar", "foo", "grandchild"])
+        bar = self.child["bar"]
+        self.assertEqual(bar.__class__, PretendContainer)
+        baz = bar["baz"]
+        self.assertEqual(self.baz, baz)
 
-        # XXX Manipulation of Extra and Annotations is not tested
+    def verify_tree_removed(self):
+        self.assertEqual(self.parent.keys(), [])
 
-        # XXX Changing directories into files or vice versa is not supported
 
 def test_suite():
     s = unittest.TestSuite()
-    s.addTest(unittest.makeSuite(TestCommitter))
+    s.addTest(unittest.makeSuite(TestCommitterModule))
+    s.addTest(unittest.makeSuite(TestCheckerClass))
+    s.addTest(unittest.makeSuite(TestCommitterClass))
     return s
 
 def test_main():