[Zope3-checkins] CVS: Zope3/src/zope/app/tests - test_size.py:1.2

Steve Alexander steve@cat-box.net
Fri, 27 Dec 2002 13:22:59 -0500


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

Modified Files:
	test_size.py 
Log Message:
units should be singular.
added a sized adapter for containers that presents the number of items
contained.
If you have a kind of container for which it is expensive to get the
number of items contained, then you should make an ISized for that
container.


=== Zope3/src/zope/app/tests/test_size.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/tests/test_size.py:1.1	Fri Dec 27 10:22:52 2002
+++ Zope3/src/zope/app/tests/test_size.py	Fri Dec 27 13:22:59 2002
@@ -13,7 +13,6 @@
 ##############################################################################
 import unittest
 
-from zope.app.size import DefaultSized
 from zope.app.interfaces.size import ISized
 
 class DummyObject:
@@ -26,11 +25,16 @@
 
 class Test(unittest.TestCase):
 
+    def testImplementsISized(self):
+        from zope.app.size import DefaultSized
+        sized = DefaultSized(object())
+        self.assert_(ISized.isImplementedBy(sized))
+        
     def testSizeWithBytes(self):
         from zope.app.size import DefaultSized
         obj = DummyObject(1023)
         sized = DefaultSized(obj)
-        self.assertEqual(sized.sizeForSorting(), ('bytes', 1023))
+        self.assertEqual(sized.sizeForSorting(), ('byte', 1023))
         self.assertEqual(sized.sizeForDisplay(), u'1 KB')
 
     def testSizeWithNone(self):
@@ -50,15 +54,19 @@
         from zope.app.size import DefaultSized
         
         sized = DefaultSized(DummyObject(0))
-        self.assertEqual(sized.sizeForSorting(), ('bytes', 0))
+        self.assertEqual(sized.sizeForSorting(), ('byte', 0))
+        self.assertEqual(sized.sizeForDisplay(), u'0 KB')
+        
+        sized = DefaultSized(DummyObject(1))
+        self.assertEqual(sized.sizeForSorting(), ('byte', 1))
         self.assertEqual(sized.sizeForDisplay(), u'1 KB')
         
         sized = DefaultSized(DummyObject(2048))
-        self.assertEqual(sized.sizeForSorting(), ('bytes', 2048))
+        self.assertEqual(sized.sizeForSorting(), ('byte', 2048))
         self.assertEqual(sized.sizeForDisplay(), u'2 KB')
         
         sized = DefaultSized(DummyObject(2000000))
-        self.assertEqual(sized.sizeForSorting(), ('bytes', 2000000))
+        self.assertEqual(sized.sizeForSorting(), ('byte', 2000000))
         self.assertEqual(sized.sizeForDisplay(), u'1.91 MB')
     
 def test_suite():