[Zodb-checkins] SVN: ZODB/branches/tseaver-better_repozo_tests/src/ZODB/scripts/tests/test_repozo.py Add tests for 'checksum'.
Tres Seaver
tseaver at palladion.com
Fri May 14 13:46:21 EDT 2010
Log message for revision 112308:
Add tests for 'checksum'.
Changed:
U ZODB/branches/tseaver-better_repozo_tests/src/ZODB/scripts/tests/test_repozo.py
-=-
Modified: ZODB/branches/tseaver-better_repozo_tests/src/ZODB/scripts/tests/test_repozo.py
===================================================================
--- ZODB/branches/tseaver-better_repozo_tests/src/ZODB/scripts/tests/test_repozo.py 2010-05-14 17:45:41 UTC (rev 112307)
+++ ZODB/branches/tseaver-better_repozo_tests/src/ZODB/scripts/tests/test_repozo.py 2010-05-14 17:46:21 UTC (rev 112308)
@@ -77,12 +77,8 @@
self.close()
-class Test_dofile(unittest.TestCase):
+class FileopsBase:
- def _callFUT(self, func, fp, n):
- from ZODB.scripts.repozo import dofile
- return dofile(func, fp, n)
-
def _makeChunks(self):
from ZODB.scripts.repozo import READCHUNK
return ['x' * READCHUNK, 'y' * READCHUNK, 'z']
@@ -93,6 +89,13 @@
text = ''.join(self._makeChunks())
return StringIO(text)
+
+class Test_dofile(unittest.TestCase, FileopsBase):
+
+ def _callFUT(self, func, fp, n):
+ from ZODB.scripts.repozo import dofile
+ return dofile(func, fp, n)
+
def test_empty_read_all(self):
chunks = []
file = self._makeFile('')
@@ -121,6 +124,35 @@
self.assertEqual(bytes, 42)
self.assertEqual(chunks, ['x' * 42])
+
+class Test_checksum(unittest.TestCase, FileopsBase):
+
+ def _callFUT(self, fp, n):
+ from ZODB.scripts.repozo import checksum
+ return checksum(fp, n)
+
+ def test_empty_read_all(self):
+ file = self._makeFile('')
+ sum = self._callFUT(file, None)
+ self.assertEqual(sum, md5('').hexdigest())
+
+ def test_empty_read_count(self):
+ file = self._makeFile('')
+ sum = self._callFUT(file, 42)
+ self.assertEqual(sum, md5('').hexdigest())
+
+ def test_nonempty_read_all(self):
+ file = self._makeFile()
+ sum = self._callFUT(file, None)
+ self.assertEqual(sum, md5(''.join(self._makeChunks())).hexdigest())
+
+ def test_nonempty_read_count(self):
+ chunks = []
+ file = self._makeFile()
+ sum = self._callFUT(file, 42)
+ self.assertEqual(sum, md5('x' * 42).hexdigest())
+
+
class TestBase:
_repository_directory = None
@@ -469,6 +501,7 @@
def test_suite():
return unittest.TestSuite([
unittest.makeSuite(Test_dofile),
+ unittest.makeSuite(Test_checksum),
unittest.makeSuite(Test_delete_old_backups),
unittest.makeSuite(Test_do_full_backup),
unittest.makeSuite(Test_do_incremental_backup),
More information about the Zodb-checkins
mailing list