Mercurial > mozilla > hg > ProfileManager
changeset 74:b6bb59b79525
* return the backed-up profile
* further test restoring profiles
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 07 May 2010 17:09:32 -0700 |
parents | 1cfd259f74cf |
children | a63dd19807c8 |
files | profilemanager/manager.py profilemanager/tests/test.py |
diffstat | 2 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/profilemanager/manager.py Fri May 07 16:30:34 2010 -0700 +++ b/profilemanager/manager.py Fri May 07 17:09:32 2010 -0700 @@ -297,6 +297,9 @@ if not os.listdir(backups_dir): shutil.rmtree(backups_dir) + # return which backup is restored + return backup + def temporary(self): """make a temporary profile""" raise NotImplementedError
--- a/profilemanager/tests/test.py Fri May 07 16:30:34 2010 -0700 +++ b/profilemanager/tests/test.py Fri May 07 17:09:32 2010 -0700 @@ -46,12 +46,26 @@ # Test dated backups manager.backup('testprofile') -old_backups = manager.backups('testprofile')[0] +old_backups = manager.backups('testprofile') +assert len(old_backups) == 1, "Expected one backup, instead got %d" % len(old_backups) old_time = int(time.time()) time.sleep(3) manager.backup('testprofile') +new_backups = manager.backups('testprofile') +assert len(new_backups) == 2, "Expected two backups, instead got %d" % len(new_backups) +restore_time = old_time + 1 +restored = manager.restore('testprofile', date=restore_time) +assert restored == old_backups[0], "Tried to restore from %d [%s], but got [%s]" % (restore_time, old_backups[0], restored) # TODO: test with alternate forms of date +# Restore the newest profile +restored = manager.restore('testprofile') +assert restored != old_backups[0], "Tried to restore the newest but got the old one" +manager.restore('testprofile', delete=True) +manager.restore('testprofile', delete=True) +assert not manager.backups() +assert manager.list() == ['testprofile'] + # Cleanup: manager.remove('testprofile') assert manager.list() == []