Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
YACHT-1094: Fixed TestTableRestoreService
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslaw-jasinski committed Nov 15, 2018
1 parent 6b8728b commit b745d69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
24 changes: 8 additions & 16 deletions src/restore/table/table_restore_service.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
import logging
import uuid

from src.backup.datastore.backup_finder import BackupFinder
from src.restore.list.backup_list_restore_service import \
BackupListRestoreRequest, BackupItem, BackupListRestoreService
from src.restore.status.restoration_job_status_service import \
RestorationJobStatusService
from src.backup.datastore.backup_finder import BackupFinder


class TableRestoreService(object):
@classmethod
def restore(cls, table_reference, target_dataset_id, restoration_datetime):
backup = BackupFinder.for_table(table_reference, restoration_datetime)

restore_request = BackupListRestoreRequest([BackupItem(backup.key)],
target_dataset_id)

restoration_job_id = str(uuid.uuid4())
logging.info("Created restoration_job_id: %s", restoration_job_id)
restore_request = BackupListRestoreRequest(
[BackupItem(backup.key)], None, target_dataset_id, None, None)

BackupListRestoreService().restore(restoration_job_id, restore_request)
restoration_job_id = BackupListRestoreService().restore(restore_request)
logging.info("Scheduled restoration job: %s", restoration_job_id)

restore_data = {
return {
'restorationJobId': restoration_job_id,
'restorationStatusEndpoint':
RestorationJobStatusService.get_status_endpoint(
restoration_job_id),
'restorationWarningsOnlyStatusEndpoint':
RestorationJobStatusService.get_warnings_only_status_endpoint(
restoration_job_id)
'restorationStatusEndpoint': RestorationJobStatusService.get_status_endpoint(restoration_job_id),
'restorationWarningsOnlyStatusEndpoint': RestorationJobStatusService.get_warnings_only_status_endpoint(restoration_job_id)
}
return restore_data
4 changes: 2 additions & 2 deletions tests/restore/table/test_table_restore_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ def test_service_call_backup_list_restore_with_one_item_only(
restoration_datetime)
# then
expected_restore_request = BackupListRestoreRequest(
[BackupItem(backup.key)], target_dataset_id)
restore.assert_called_once_with("123", expected_restore_request)
[BackupItem(backup.key)], None, target_dataset_id, None, None)
restore.assert_called_once_with(expected_restore_request)

0 comments on commit b745d69

Please sign in to comment.