test: Add tests for bench restore

This commit is contained in:
Gavin D'souza 2020-11-14 11:11:19 +05:30
parent 05c8e3c5a7
commit 22b752ac21

View file

@ -201,9 +201,7 @@ class TestCommands(BaseTestCommands):
# test 5: take a backup with --compress
self.execute("bench --site {site} backup --with-files --compress")
self.assertEquals(self.returncode, 0)
compressed_files = glob(site_backup_path + "/*.tgz")
self.assertGreater(len(compressed_files), 0)
@ -244,6 +242,18 @@ class TestCommands(BaseTestCommands):
database = fetch_latest_backups()["database"]
self.assertTrue(exists_in_backup(backup["excludes"]["excludes"], database))
def test_restore(self):
# test 1: bench restore from full backup
self.execute("bench --site {site} backup --ignore-backup-conf")
database = fetch_latest_backups()["database"]
self.execute("bench --site {site} restore {database}", {"database": database})
# test 2: restore from partial backup
self.execute("bench --site {site} backup --exclude 'ToDo")
database = fetch_latest_backups(partial=True)["database"]
self.execute("bench --site {site} restore {database}", {"database": database})
self.assertEquals(self.returncode, 1)
def test_partial_restore(self):
_now = now()
for num in range(10):