コード例 #1
0
ファイル: test_restoremanager.py プロジェクト: code42/py42
 def test_send_stream_calls_start_push_restore_with_expected_args(
         self, push_service, single_file_selection):
     restore_job_manager = RestoreJobManager(push_service, TEST_DEVICE_GUID,
                                             TEST_SESSION_ID)
     restore_job_manager.send_stream(
         TEST_RESTORE_PATH,
         TEST_NODE_GUID,
         TEST_ACCEPTING_GUID,
         single_file_selection,
         TEST_BACKUP_SET_ID,
         False,
         False,
     )
     push_service.start_push_restore.assert_called_once_with(
         TEST_DEVICE_GUID,
         TEST_ACCEPTING_GUID,
         TEST_SESSION_ID,
         TEST_NODE_GUID,
         TEST_RESTORE_PATH,
         [{
             "backupSetId": TEST_BACKUP_SET_ID,
             "files": [single_file_selection[0].file],
         }],
         1,
         1,
         show_deleted=False,
         file_location=None,
         existing_files=PushRestoreExistingFiles.RENAME_ORIGINAL,
         permit_restore_to_different_os_version=False,
     )
コード例 #2
0
ファイル: test_restoremanager.py プロジェクト: code42/py42
 def test_send_stream_when_using_original_directory_and_the_same_device_guid_start_push_restore_with_expected_args(
         self, push_service, single_file_selection):
     restore_job_manager = RestoreJobManager(push_service, TEST_DEVICE_GUID,
                                             TEST_SESSION_ID)
     restore_job_manager.send_stream(
         PushRestoreLocation.ORIGINAL_LOCATION,
         TEST_NODE_GUID,
         TEST_DEVICE_GUID,
         single_file_selection,
         TEST_BACKUP_SET_ID,
         False,
         True,
     )
     push_service.start_push_restore.assert_called_once_with(
         TEST_DEVICE_GUID,
         TEST_DEVICE_GUID,
         TEST_SESSION_ID,
         TEST_NODE_GUID,
         "",
         [{
             "backupSetId": TEST_BACKUP_SET_ID,
             "files": [single_file_selection[0].file],
         }],
         1,
         1,
         show_deleted=False,
         file_location=PushRestoreLocation.ORIGINAL_LOCATION,
         existing_files=PushRestoreExistingFiles.OVERWRITE_ORIGINAL,
         permit_restore_to_different_os_version=False,
     )
コード例 #3
0
ファイル: test_restoremanager.py プロジェクト: code42/py42
    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
コード例 #4
0
ファイル: test_restoremanager.py プロジェクト: code42/py42
    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,
        )
コード例 #5
0
ファイル: test_restoremanager.py プロジェクト: code42/py42
 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)
コード例 #6
0
 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,
     )
コード例 #7
0
ファイル: test_restoremanager.py プロジェクト: code42/py42
 def test_restore_job_manager_constructs_successfully(
         self, storage_archive_service):
     assert RestoreJobManager(storage_archive_service, TEST_DEVICE_GUID,
                              TEST_SESSION_ID)