# HG changeset patch # User Jeff Hammel # Date 1273275034 25200 # Node ID 1cfd259f74cfca8ec81dec5f657da2ecb31d55c4 # Parent 619f5918b998230ae0a134d6938e24326e1e30e6 finish dated backups, untested diff -r 619f5918b998 -r 1cfd259f74cf profilemanager/manager.py --- 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)) diff -r 619f5918b998 -r 1cfd259f74cf profilemanager/tests/test.py --- 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')