示例#1
0
 def test_exit_upload_exception(self, tmpdir, caplog):
     backup_dir = self.create_single_directory(tmpdir)
     args = MockArgs(tmpdir)
     args.backup_directory = backup_dir
     client = get_stubbed_error_client()
     backup = Backup(args, client)
     backup.config.upload_retry_time = 0
     backup.run()
     backups = backup.database.get_backups(os.path.join(tmpdir, 'test_dir'))
     assert len(backups) == 0
示例#2
0
 def test_run_single_single_part(self, tmpdir):
     backup_dir = self.create_single_directory(tmpdir)
     args = MockArgs(tmpdir)
     args.backup_directory = backup_dir
     client = get_stubbed_single_single_client()
     backup = Backup(args, client)
     backup.run(client)
     backups = backup.database.get_backups(os.path.join(tmpdir, 'test_dir'))
     assert len(backups) == 1
     assert backups[0][6] == 0
示例#3
0
 def test_run_recursive_single_part(self, tmpdir):
     backup_dir = self.create_recursive_directory(tmpdir)
     args = MockArgs(tmpdir)
     args.backup_directory = backup_dir
     args.recursive = True
     client = get_stubbed_recursive_single_client()
     backup = Backup(args, client)
     backup.run(client)
     backups_1 = backup.database.get_backups(
         os.path.join(tmpdir, 'test_dir/sub_dir_1'))
     backups_2 = backup.database.get_backups(
         os.path.join(tmpdir, 'test_dir/sub_dir_2'))
     assert len(backups_1) == 1
     assert backups_1[0][6] == 0
     assert len(backups_2) == 1
     assert backups_2[0][6] == 0
示例#4
0
 def test_exit_directory_exception(self, tmpdir, caplog):
     backup_dir = self.create_single_directory(tmpdir)
     changes = {'temp_directory': '/does/not/exist/'}
     args = MockArgs(tmpdir, changes)
     args.backup_directory = backup_dir
     client = get_stubbed_check_client()
     with pytest.raises(SystemExit) as excinfo:
         backup = Backup(args, client)
     assert excinfo.type == SystemExit
     assert 'Cannot open' in caplog.text
示例#5
0
 def test_exit_config_exception(self, tmpdir, caplog):
     backup_dir = self.create_single_directory(tmpdir)
     changes = {'max_archive_size': 1889}
     args = MockArgs(tmpdir, changes)
     args.backup_directory = backup_dir
     client = get_stubbed_check_client()
     with pytest.raises(SystemExit) as excinfo:
         backup = Backup(args, client)
     assert excinfo.type == SystemExit
     assert 'power of 2' in caplog.text
示例#6
0
 def test_exit_database_exception(self, tmpdir, caplog):
     db_file_path = os.path.join(tmpdir, 'lambert.sqlite')
     with open(db_file_path, 'w+') as f:
         f.write('This is not a valid database file')
     backup_dir = self.create_single_directory(tmpdir)
     changes = {'database_file': db_file_path}
     args = MockArgs(tmpdir, changes)
     args.backup_directory = backup_dir
     client = get_stubbed_check_client()
     with pytest.raises(SystemExit) as excinfo:
         backup = Backup(args, client)
     assert excinfo.type == SystemExit
     assert 'not correctly formatted' in caplog.text
示例#7
0
 def test_deleted(self, tmpdir):
     backup_dir = self.create_single_directory(tmpdir)
     args = MockArgs(tmpdir)
     args.backup_directory = backup_dir
     client = get_stubbed_deleted_client()
     backup = Backup(args, client)
     backup.run(client)
     backup.run(client)
     backup.run(client)
     backup_path = os.path.join(tmpdir, 'test_dir')
     backups = backup.database.get_backups(backup_path)
     assert len(backups) == 2
     assert backups[0][2] == 'archive-id-234'
示例#8
0
 def test_init(self, tmpdir):
     args = MockArgs(tmpdir)
     client = get_stubbed_check_client()
     backup = Backup(args, client)
     assert type(backup.config) == Config
     assert type(backup.database) == Database