[Zope3-checkins] CVS: Zope3/src/zope/app/services/tests - test_useconfiguration.py:1.4

Guido van Rossum guido@python.org
Thu, 12 Jun 2003 14:58:50 -0400


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

Modified Files:
	test_useconfiguration.py 
Log Message:
Add unit tests for (a) removing duplicates and (b) equivalence between
absolute and relative paths.


=== Zope3/src/zope/app/services/tests/test_useconfiguration.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/services/tests/test_useconfiguration.py:1.3	Sat Jun  7 01:32:01 2003
+++ Zope3/src/zope/app/services/tests/test_useconfiguration.py	Thu Jun 12 14:58:50 2003
@@ -33,12 +33,13 @@
         obj = UseConfiguration(C())
         verifyObject(IUseConfiguration, obj)
 
-    def test(self):
+    def testBasic(self):
         obj = UseConfiguration(C())
         self.failIf(obj.usages())
         obj.addUsage('/a/b')
         obj.addUsage('/c/d')
         obj.addUsage('/c/e')
+        obj.addUsage('/c/d')
         locs = list(obj.usages())
         locs.sort()
         self.assertEqual(locs, ['/a/b', '/c/d', '/c/e'])
@@ -46,6 +47,22 @@
         locs = list(obj.usages())
         locs.sort()
         self.assertEqual(locs, ['/a/b', '/c/e'])
+        obj.removeUsage('/c/d')
+        self.assertEqual(locs, ['/a/b', '/c/e'])
+
+    def testRelativeAbsolute(self):
+        obj = UseConfiguration(C())
+        # Hack the object to have a parent path
+        obj.pp = "/a/"
+        obj.pplen = len(obj.pp)
+        obj.addUsage("foo")
+        self.assertEqual(obj.usages(), ("/a/foo",))
+        obj.removeUsage("/a/foo")
+        self.assertEqual(obj.usages(), ())
+        obj.addUsage("/a/bar")
+        self.assertEqual(obj.usages(), ("/a/bar",))
+        obj.removeUsage("bar")
+        self.assertEqual(obj.usages(), ())
 
 def test_suite():
     return TestSuite((