[Zodb-checkins] SVN: ZODB/branches/tseaver-better_repozo_tests/src/ZODB/scripts/tests/test_repozo.py Add tests for 'gen_filename'.

Tres Seaver tseaver at palladion.com
Fri May 14 13:49:53 EDT 2010


Log message for revision 112311:
  Add tests for 'gen_filename'.

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:48:26 UTC (rev 112310)
+++ ZODB/branches/tseaver-better_repozo_tests/src/ZODB/scripts/tests/test_repozo.py	2010-05-14 17:49:53 UTC (rev 112311)
@@ -263,7 +263,53 @@
         self.assertEqual(ofp._written, [x for x in 'ABC'])
         self.failUnless(ofp._closed)
 
+_marker = object()
+class Test_gen_filename(OptionsTestBase, unittest.TestCase):
 
+    def _callFUT(self, options, ext=_marker):
+        from ZODB.scripts.repozo import gen_filename
+        if ext is _marker:
+            return gen_filename(options)
+        return gen_filename(options, ext)
+
+    def test_explicit_ext(self):
+        options = self._makeOptions(test_now = (2010, 5, 14, 12, 52, 31))
+        fn = self._callFUT(options, '.txt')
+        self.assertEqual(fn, '2010-05-14-12-52-31.txt')
+
+    def test_full_no_gzip(self):
+        options = self._makeOptions(test_now = (2010, 5, 14, 12, 52, 31),
+                                    full = True,
+                                    gzip = False,
+                                   )
+        fn = self._callFUT(options)
+        self.assertEqual(fn, '2010-05-14-12-52-31.fs')
+
+    def test_full_w_gzip(self):
+        options = self._makeOptions(test_now = (2010, 5, 14, 12, 52, 31),
+                                    full = True,
+                                    gzip = True,
+                                   )
+        fn = self._callFUT(options)
+        self.assertEqual(fn, '2010-05-14-12-52-31.fsz')
+
+    def test_incr_no_gzip(self):
+        options = self._makeOptions(test_now = (2010, 5, 14, 12, 52, 31),
+                                    full = False,
+                                    gzip = False,
+                                   )
+        fn = self._callFUT(options)
+        self.assertEqual(fn, '2010-05-14-12-52-31.deltafs')
+
+    def test_incr_w_gzip(self):
+        options = self._makeOptions(test_now = (2010, 5, 14, 12, 52, 31),
+                                    full = False,
+                                    gzip = True,
+                                   )
+        fn = self._callFUT(options)
+        self.assertEqual(fn, '2010-05-14-12-52-31.deltafsz')
+
+
 class Test_delete_old_backups(OptionsTestBase, unittest.TestCase):
 
     def _makeOptions(self, filenames=()):
@@ -592,6 +638,7 @@
         unittest.makeSuite(Test_checksum),
         unittest.makeSuite(Test_copyfile),
         unittest.makeSuite(Test_concat),
+        unittest.makeSuite(Test_gen_filename),
         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