comparison profilemanager/tests/test.py @ 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 e76a122d8622
comparison
equal deleted inserted replaced
73:1cfd259f74cf 74:b6bb59b79525
44 assert not backups 44 assert not backups
45 # TODO: test the backup with a populated profile 45 # TODO: test the backup with a populated profile
46 46
47 # Test dated backups 47 # Test dated backups
48 manager.backup('testprofile') 48 manager.backup('testprofile')
49 old_backups = manager.backups('testprofile')[0] 49 old_backups = manager.backups('testprofile')
50 assert len(old_backups) == 1, "Expected one backup, instead got %d" % len(old_backups)
50 old_time = int(time.time()) 51 old_time = int(time.time())
51 time.sleep(3) 52 time.sleep(3)
52 manager.backup('testprofile') 53 manager.backup('testprofile')
54 new_backups = manager.backups('testprofile')
55 assert len(new_backups) == 2, "Expected two backups, instead got %d" % len(new_backups)
56 restore_time = old_time + 1
57 restored = manager.restore('testprofile', date=restore_time)
58 assert restored == old_backups[0], "Tried to restore from %d [%s], but got [%s]" % (restore_time, old_backups[0], restored)
53 # TODO: test with alternate forms of date 59 # TODO: test with alternate forms of date
60
61 # Restore the newest profile
62 restored = manager.restore('testprofile')
63 assert restored != old_backups[0], "Tried to restore the newest but got the old one"
64 manager.restore('testprofile', delete=True)
65 manager.restore('testprofile', delete=True)
66 assert not manager.backups()
67 assert manager.list() == ['testprofile']
54 68
55 # Cleanup: 69 # Cleanup:
56 manager.remove('testprofile') 70 manager.remove('testprofile')
57 assert manager.list() == [] 71 assert manager.list() == []
58 f = file(profiles, 'w') 72 f = file(profiles, 'w')