Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit ddce7d7

Browse files
committed
Updated archived endpoit and its test case
1 parent cb606cd commit ddce7d7

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

examples/image_streamer/os_volumes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
# Retrieve archived logs of the OS Volume
6464
print("Retrieve archived logs of the OS Volume")
65-
if image_streamer_client.os_volumes.download_archive(os_volume['uri'], destination_archive_path):
65+
if image_streamer_client.os_volumes.download_archive(os_volume['name'], destination_archive_path):
6666
print(" File downloaded successfully.")
6767
else:
6868
print(" Error downloading the file.")

hpOneView/image_streamer/resources/os_volumes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,18 @@ def get_by_name(self, name):
107107
"""
108108
return self._client.get_by_name(name)
109109

110-
def download_archive(self, id_or_uri, file_path):
110+
def download_archive(self, name, file_path):
111111
"""
112-
Download the details of the archived OS Volume.
112+
Download archived logs of the OS Volume.
113113
114114
Args:
115-
id_or_uri: ID or URI of the OS Volume.
115+
name: Name of the OS Volume.
116116
file_path (str): Destination file path.
117117
118118
Returns:
119119
bool: Indicates if the resource was successfully downloaded.
120120
"""
121-
uri = self.URI + "/archive/" + extract_id_from_uri(id_or_uri)
121+
uri = self.URI + "/archive/" + name
122122
return self._client.download(uri, file_path)
123123

124124
def get_storage(self, id_or_uri):

tests/unit/image_streamer/resources/test_os_volumes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,11 @@ def test_download_archive_called_once_with_id(self, mock_download):
8282

8383
@mock.patch.object(ResourceClient, 'download')
8484
def test_download_archive_called_once_with_uri(self, mock_download):
85-
uri = '/rest/os-volumes/archive/3518be0e-17c1-4189-8f81-83f3724f6155'
85+
name = "fake"
86+
uri = '/rest/os-volumes/archive/fake'
8687

87-
self._client.download_archive(uri, "~/archive.log")
88-
89-
mock_download.assert_called_once_with('/rest/os-volumes/archive/3518be0e-17c1-4189-8f81-83f3724f6155',
90-
'~/archive.log')
88+
self._client.download_archive(name, "~/archive.log")
89+
mock_download.assert_called_once_with(uri, '~/archive.log')
9190

9291
@mock.patch.object(ResourceClient, 'get')
9392
def test_get_storage(self, mock_get):

0 commit comments

Comments
 (0)