changeset 73:1cfd259f74cf

finish dated backups, untested
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 07 May 2010 16:30:34 -0700
parents 619f5918b998
children b6bb59b79525
files profilemanager/manager.py profilemanager/tests/test.py
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/profilemanager/manager.py	Fri May 07 16:09:06 2010 -0700
+++ b/profilemanager/manager.py	Fri May 07 16:30:34 2010 -0700
@@ -218,6 +218,7 @@
         """
 
         assert not (date and delete), 'date and delete cannot be used in conjunction'
+        orig_date = date
 
         # get the path to the profile
         path = self.path(profile)
@@ -248,7 +249,10 @@
                 date = time.mktime(date.timetuple())
             
             for backup in backups:
-                raise NotImplementedError
+                if backup[1] < date:
+                    break
+            else:
+                raise NoBackupError("No backups for profile %s in %s earlier than %s" % (profile, self.profiles, orig_date))
         else:
             if not backups:
                 raise NoBackupError("No backups for profile %s in %s" % (profile, self.profiles))
--- a/profilemanager/tests/test.py	Fri May 07 16:09:06 2010 -0700
+++ b/profilemanager/tests/test.py	Fri May 07 16:30:34 2010 -0700
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
 import os
+import time
 from profilemanager import ProfileManager
 
 # Get the path to the test profiles.ini file:
@@ -43,6 +44,13 @@
 assert not backups
 # TODO: test the backup with a populated profile
 
+# Test dated backups
+manager.backup('testprofile')
+old_backups = manager.backups('testprofile')[0]
+old_time = int(time.time())
+time.sleep(3)
+manager.backup('testprofile')
+# TODO: test with alternate forms of date
 
 # Cleanup:
 manager.remove('testprofile')