[Zope3-checkins] CVS: Zope3/src/zope/fssync/tests - test_fsmerger.py:1.9 test_merger.py:1.13
Guido van Rossum
guido@python.org
Thu, 29 May 2003 11:07:31 -0400
Update of /cvs-repository/Zope3/src/zope/fssync/tests
In directory cvs.zope.org:/tmp/cvs-serv32663/tests
Modified Files:
test_fsmerger.py test_merger.py
Log Message:
Proper unit tests for "sticky conflicts" (the "C" flag remains until
the file is edited) and proper implementation following the unit tests.
=== Zope3/src/zope/fssync/tests/test_fsmerger.py 1.8 => 1.9 ===
--- Zope3/src/zope/fssync/tests/test_fsmerger.py:1.8 Wed May 28 15:09:22 2003
+++ Zope3/src/zope/fssync/tests/test_fsmerger.py Thu May 29 11:07:30 2003
@@ -66,7 +66,7 @@
# not None, entries are also synthesized for the directory
# contents.
path = join(dir, path)
- if entry is not None:
+ if entry is not None and not callable(entry):
self.addentry(path, entry)
if isinstance(data, dict):
self.ensuredir(path)
@@ -86,6 +86,8 @@
f.write(data)
finally:
f.close()
+ if callable(entry):
+ self.addentry(path, entry(path))
return path
def addorigfile(self, dir, path, data):
@@ -277,10 +279,35 @@
self.make_conflict_entry, self.entry)
def make_conflict_entry(self, local):
- # Helper for test_merge_conflict
+ # Helper for test_*_conflict
e = {"conflict": os.path.getmtime(local)}
e.update(self.entry)
return e
+
+ # Tests for sticky conflict reporting
+
+ def test_sticky_conflict(self):
+ conflict = "<<<<<<< foo\nl\n=======\nr\n>>>>>>> foo\n"
+ self.mergetest("foo", conflict, "r\n", "r\n",
+ self.make_conflict_entry, self.entry,
+ ["C %l"], conflict, "r\n", "r\n",
+ self.make_conflict_entry, self.entry)
+
+ def test_unstuck_conflict(self):
+ conflict_entry = {"conflict": 12345}
+ conflict_entry.update(self.entry)
+ self.mergetest("foo", "resolved\n", "r\n", "r\n",
+ conflict_entry, self.entry,
+ ["M %l"], "resolved\n", "r\n", "r\n",
+ self.entry, self.entry)
+
+ def test_cleared_conflict(self):
+ conflict_entry = {"conflict": 12345}
+ conflict_entry.update(self.entry)
+ self.mergetest("foo", "r\n", "r\n", "r\n",
+ conflict_entry, self.entry,
+ [], "r\n", "r\n", "r\n",
+ self.entry, self.entry)
# Tests for added files: local, remote, both
=== Zope3/src/zope/fssync/tests/test_merger.py 1.12 => 1.13 ===
--- Zope3/src/zope/fssync/tests/test_merger.py:1.12 Wed May 28 16:24:03 2003
+++ Zope3/src/zope/fssync/tests/test_merger.py Thu May 29 11:07:30 2003
@@ -198,10 +198,6 @@
action, state = m.classify_files(local, orig, remote)
self.assertEqual((action, state), ("Nothing", "Conflict"))
self.assertEqual(lentry.get("conflict"), mtime)
- lentry["conflict"] = mtime+100
- action, state = m.classify_files(local, orig, remote)
- self.assertEqual((action, state), ("Nothing", "Modified"))
- self.assertEqual(lentry.get("conflict"), None)
# XXX need test cases for anomalies, e.g. files missing or present
# in spite of metadata, or directories instead of files, etc.