Skip to content

Commit

Permalink
Add missing tests (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juliya Smith committed Jun 3, 2020
1 parent b899f3e commit adb942c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/_internal/clients/storage/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,67 @@ def storage_archive_client(mocker):


class TestStorageArchiveClient(object):
def test_search_paths_calls_get_with_expected_params(self, session):
storage_archive_client = StorageArchiveClient(session)
storage_archive_client.search_paths(
"session_id", "device_id", "regex", 1000, "timestamp", True
)
session.get.assert_called_once_with(
"/api/WebRestoreSearch",
params={
"webRestoreSessionId": "session_id",
"guid": "device_id",
"regex": "regex",
"maxResults": 1000,
"timestamp": "timestamp",
"showDeleted": True,
},
)

def test_get_file_size_calls_get_with_expected_params(self, session):
storage_archive_client = StorageArchiveClient(session)
storage_archive_client.get_file_size(
"device_guid", "file_id", "timestamp", True, "backupset_id"
)
session.get.assert_called_once_with(
u"/api/WebRestoreFileSize",
params={
"guid": "device_guid",
"fileId": "file_id",
"timestamp": "timestamp",
"showDeleted": True,
"backupSetId": "backupset_id",
},
)

def test_get_file_path_metadata_calls_get_with_expected_params(self, session):
storage_archive_client = StorageArchiveClient(session)
storage_archive_client.get_file_path_metadata(
"session",
"guid",
"file_id",
"timestamp",
True,
"batch_size",
"lastBatchId",
"backupset_id",
True,
)
session.get.assert_called_once_with(
u"/api/WebRestoreTreeNode",
params={
"webRestoreSessionId": "session",
"guid": "guid",
"fileId": "file_id",
"timestamp": "timestamp",
"showDeleted": True,
"batchSize": "batch_size",
"lastBatchFileId": "lastBatchId",
"backupSetId": "backupset_id",
"includeOsMetadata": True,
},
)

def test_create_restore_session_calls_post_with_correct_url(self, mocker, session):
storage_archive_client = StorageArchiveClient(session)
storage_archive_client.create_restore_session(DEVICE_GUID)
Expand Down
17 changes: 17 additions & 0 deletions tests/modules/test_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ class TestArchiveModule(object):
_TEST_DAYS = 42
_TEST_ID = 424242

def test_stream_from_backup_calls_get_archive_accessor_with_expected_params(self, mocker):
archive = _get_module(mocker)
archive.stream_from_backup("path", "device_guid", "dest_guid", "password", "encryption_key")
archive._archive_accessor_manager.get_archive_accessor.assert_called_once_with(
"device_guid",
destination_guid="dest_guid",
private_password="password",
encryption_key="encryption_key",
)

def test_get_backup_sets_calls_archive_client_get_backup_sets_with_expected_params(
self, mocker
):
archive = _get_module(mocker)
archive.get_backup_sets("device_guid", "dest_guid")
archive._archive_client.get_backup_sets.assert_called_once_with("device_guid", "dest_guid")

def test_get_all_org_restore_history_calls_get_all_restore_history_with_expected_id(
self, mocker
):
Expand Down

0 comments on commit adb942c

Please sign in to comment.