def test_get_stream_when_multiple_files_selected_calls_start_web_restore_with_correct_args( self, mocker, storage_archive_service, double_file_selection): mock_start_restore_response(mocker, storage_archive_service, GetWebRestoreJobResponses.NOT_DONE) mock_get_restore_status_responses(mocker, storage_archive_service, [GetWebRestoreJobResponses.DONE]) restore_job_manager = RestoreJobManager(storage_archive_service, TEST_DEVICE_GUID, TEST_SESSION_ID) restore_job_manager.get_stream(TEST_BACKUP_SET_ID, double_file_selection, False) expected_restore_groups = [{ "backupSetId": TEST_BACKUP_SET_ID, "files": [ double_file_selection[0].file, double_file_selection[1].file, ], }] storage_archive_service.start_restore.assert_called_once_with( TEST_DEVICE_GUID, TEST_SESSION_ID, expected_restore_groups, 1 + 4, 2 + 5, 3 + 6, show_deleted=False, )
def test_get_stream_when_response_missing_status_polls_job_status_until_job_is_complete( self, mocker, storage_archive_service, single_file_selection): mock_start_restore_response(mocker, storage_archive_service, GetWebRestoreJobResponses.NOT_DONE) mock_get_restore_status_responses( mocker, storage_archive_service, [ GetWebRestoreJobResponses.NOT_DONE, GetWebRestoreJobResponses.NOT_DONE, GetWebRestoreJobResponses.MISSING_STATUS, ], ) restore_job_manager = RestoreJobManager( storage_archive_service, TEST_DEVICE_GUID, TEST_SESSION_ID, job_polling_interval=0.000001, ) restore_job_manager.get_stream(TEST_BACKUP_SET_ID, single_file_selection, True) job_id = get_response_job_id(GetWebRestoreJobResponses.MISSING_STATUS) expected_call = mocker.call(job_id) storage_archive_service.get_restore_status.assert_has_calls( [expected_call, expected_call, expected_call]) assert storage_archive_service.get_restore_status.call_count == 3
def test_get_stream_calls_start_web_restore_with_correct_args( self, mocker, storage_archive_service, single_file_selection): mock_start_restore_response(mocker, storage_archive_service, GetWebRestoreJobResponses.NOT_DONE) mock_get_restore_status_responses(mocker, storage_archive_service, [GetWebRestoreJobResponses.DONE]) restore_job_manager = RestoreJobManager(storage_archive_service, TEST_DEVICE_GUID, TEST_SESSION_ID) restore_job_manager.get_stream(TEST_BACKUP_SET_ID, single_file_selection, True) expected_restore_groups = [{ u"backupSetId": TEST_BACKUP_SET_ID, u"files": [single_file_selection[0].file], }] storage_archive_service.start_restore.assert_called_once_with( TEST_DEVICE_GUID, TEST_SESSION_ID, expected_restore_groups, 1, 1, 1, show_deleted=True, )
def test_get_stream_when_successful_returns_response( self, mocker, storage_archive_service, single_file_selection, file_content_chunks, ): mock_start_restore_response(mocker, storage_archive_service, GetWebRestoreJobResponses.NOT_DONE) mock_get_restore_status_responses(mocker, storage_archive_service, [GetWebRestoreJobResponses.DONE]) stream_restore_result_response_mock(mocker, storage_archive_service, file_content_chunks) restore_job_manager = RestoreJobManager(storage_archive_service, TEST_DEVICE_GUID, TEST_SESSION_ID) assert restore_job_manager.get_stream(TEST_BACKUP_SET_ID, single_file_selection, True)