예제 #1
0
    def test_start_restore_with_required_args_calls_post_with_all_args_in_json(
            self, connection):
        storage_archive_service = StorageArchiveService(connection)
        storage_archive_service.start_restore(DEVICE_GUID,
                                              WEB_RESTORE_SESSION_ID, PATH_SET,
                                              NUM_FILES, NUM_DIRS, SIZE)

        json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]

        keys = [
            GUID_KEY,
            WEB_RESTORE_SESSION_ID_KEY,
            PATH_SET_KEY,
            NUM_FILES_KEY,
            NUM_DIRS_KEY,
            SIZE_KEY,
            ZIP_RESULT_KEY,
            EXPIRE_JOB_KEY,
            SHOW_DELETED_KEY,
            RESTORE_FULL_PATH_KEY,
            TIMESTAMP_KEY,
            BACKUP_SET_ID_KEY,
        ]

        assert sorted(json_arg.keys()) == sorted(keys)
예제 #2
0
 def test_start_restore_with_all_args_calls_post_with_all_args_in_data(
         self, connection):
     storage_archive_service = StorageArchiveService(connection)
     storage_archive_service.start_restore(
         DEVICE_GUID,
         WEB_RESTORE_SESSION_ID,
         PATH_SET,
         NUM_FILES,
         NUM_DIRS,
         SIZE,
         zip_result=True,
         expire_job=True,
         show_deleted=True,
         restore_full_path=True,
         timestamp=TIMESTAMP,
         backup_set_id=BACKUP_SET_ID,
     )
     json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]
     expected_data = {
         GUID_KEY: DEVICE_GUID,
         WEB_RESTORE_SESSION_ID_KEY: WEB_RESTORE_SESSION_ID,
         PATH_SET_KEY: PATH_SET,
         NUM_FILES_KEY: NUM_FILES,
         NUM_DIRS_KEY: NUM_DIRS,
         SIZE_KEY: SIZE,
         ZIP_RESULT_KEY: True,
         EXPIRE_JOB_KEY: True,
         SHOW_DELETED_KEY: True,
         RESTORE_FULL_PATH_KEY: True,
         TIMESTAMP_KEY: TIMESTAMP,
         BACKUP_SET_ID_KEY: BACKUP_SET_ID,
     }
     assert json_arg == expected_data
예제 #3
0
 def test_start_restore_posts_expected_data_to_expected_url(self, connection):
     storage_archive_service = StorageArchiveService(connection)
     storage_archive_service.start_restore(
         TEST_DEVICE_GUID,
         TEST_SESSION_ID,
         RESTORE_GROUPS,
         TEST_NUM_FILES,
         TEST_NUM_DIRS,
         TEST_NUM_BYTES,
         True,
         True,
         True,
         True,
     )
     expected_data = {
         "sourceComputerGuid": TEST_DEVICE_GUID,
         "webRestoreSessionId": TEST_SESSION_ID,
         "restoreGroups": RESTORE_GROUPS,
         "numFiles": TEST_NUM_FILES,
         "numDirs": TEST_NUM_DIRS,
         "numBytes": TEST_NUM_BYTES,
         "expireJob": True,
         "showDeleted": True,
         "restoreFullPath": True,
         "restoreToServer": True,
     }
     connection.post.assert_called_once_with(
         START_WEB_RESTORE_JOB_URL, json=expected_data
     )
예제 #4
0
    def test_start_restore_calls_post_with_correct_url(self, connection):
        storage_archive_service = StorageArchiveService(connection)

        storage_archive_service.start_restore(DEVICE_GUID,
                                              WEB_RESTORE_SESSION_ID, PATH_SET,
                                              NUM_FILES, NUM_DIRS, SIZE)
        assert connection.post.call_args[ARGS_INDEX][
            ARGS_INDEX] == WEB_RESTORE_JOB_URL
예제 #5
0
    def test_start_restore_calls_post_with_correct_url(self, connection):
        storage_archive_service = StorageArchiveService(connection)

        storage_archive_service.start_restore(
            TEST_DEVICE_GUID,
            TEST_SESSION_ID,
            RESTORE_GROUPS,
            TEST_NUM_FILES,
            TEST_NUM_DIRS,
            TEST_NUM_BYTES,
        )
        assert (connection.post.call_args[ARGS_INDEX][ARGS_INDEX] ==
                START_WEB_RESTORE_JOB_URL)
예제 #6
0
 def test_start_restore_with_backup_set_id_calls_post_with_backup_set_id_in_data(
         self, connection):
     storage_archive_service = StorageArchiveService(connection)
     storage_archive_service.start_restore(
         DEVICE_GUID,
         WEB_RESTORE_SESSION_ID,
         PATH_SET,
         NUM_FILES,
         NUM_DIRS,
         SIZE,
         backup_set_id=BACKUP_SET_ID,
     )
     json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]
     assert json_arg.get(BACKUP_SET_ID_KEY) == BACKUP_SET_ID
예제 #7
0
 def test_start_restore_with_timestamp_calls_post_with_timestamp_in_data(
         self, connection):
     storage_archive_service = StorageArchiveService(connection)
     storage_archive_service.start_restore(
         DEVICE_GUID,
         WEB_RESTORE_SESSION_ID,
         PATH_SET,
         NUM_FILES,
         NUM_DIRS,
         SIZE,
         timestamp=TIMESTAMP,
     )
     json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]
     assert json_arg.get(TIMESTAMP_KEY) == TIMESTAMP
예제 #8
0
 def test_start_restore_with_restore_full_path_false_calls_post_with_restore_full_path_true_in_data(
         self, connection):
     storage_archive_service = StorageArchiveService(connection)
     storage_archive_service.start_restore(
         DEVICE_GUID,
         WEB_RESTORE_SESSION_ID,
         PATH_SET,
         NUM_FILES,
         NUM_DIRS,
         SIZE,
         restore_full_path=False,
     )
     json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]
     assert json_arg.get(RESTORE_FULL_PATH_KEY) is False
예제 #9
0
 def test_start_restore_with_show_deleted_false_calls_post_with_show_deleted_false_in_data(
         self, connection):
     storage_archive_service = StorageArchiveService(connection)
     storage_archive_service.start_restore(
         DEVICE_GUID,
         WEB_RESTORE_SESSION_ID,
         PATH_SET,
         NUM_FILES,
         NUM_DIRS,
         SIZE,
         show_deleted=False,
     )
     json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]
     assert json_arg.get(SHOW_DELETED_KEY) is False
예제 #10
0
    def test_start_restore_with_expire_job_as_false_calls_post_with_expire_job_in_data(
            self, connection):
        storage_archive_service = StorageArchiveService(connection)

        storage_archive_service.start_restore(
            DEVICE_GUID,
            WEB_RESTORE_SESSION_ID,
            PATH_SET,
            NUM_FILES,
            NUM_DIRS,
            SIZE,
            expire_job=False,
        )
        json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]
        assert json_arg.get(EXPIRE_JOB_KEY) is False
예제 #11
0
    def test_start_restore_with_opt_zip_result_as_true_calls_post_with_zip_result_in_data(
            self, connection):
        storage_archive_service = StorageArchiveService(connection)

        storage_archive_service.start_restore(
            DEVICE_GUID,
            WEB_RESTORE_SESSION_ID,
            PATH_SET,
            NUM_FILES,
            NUM_DIRS,
            SIZE,
            zip_result=True,
        )
        json_arg = connection.post.call_args[KWARGS_INDEX][JSON_KEYWORD]
        assert json_arg.get(ZIP_RESULT_KEY) is True