Skip to content

Commit b114e05

Browse files
authored
Merge pull request #3 from TechConsult/favorite-storage-operations
favorite storage operations
2 parents 3584efc + e51d461 commit b114e05

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/test_storage.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ def test_templatize_storage(self, manager):
9292
assert storage.title == "my server template"
9393
assert storage.type == "template"
9494

95+
@responses.activate
96+
def test_add_storage_to_favorites(self, manager):
97+
data = Mock.mock_post("storage/01d4fcd4-e446-433b-8a9c-551a1284952e/favorite", empty_content=True)
98+
res = manager.add_storage_to_favorites("01d4fcd4-e446-433b-8a9c-551a1284952e")
99+
assert res == {}
100+
101+
@responses.activate
102+
def test_remove_storage_from_favorites(self, manager):
103+
data = Mock.mock_delete("storage/01d4fcd4-e446-433b-8a9c-551a1284952e/favorite")
104+
res = manager.remove_storage_from_favorites("01d4fcd4-e446-433b-8a9c-551a1284952e")
105+
assert res == {}
106+
95107
@responses.activate
96108
def test_storage_update(self, manager):
97109

upcloud_api/cloud_manager/storage_mixin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,17 @@ def templatize_storage(self, storage, title):
150150
body = {'storage': {'title': title}}
151151
res = self.post_request(url, body)
152152
return Storage(cloud_manager=self, **res['storage'])
153+
154+
def add_storage_to_favorites(self, storage):
155+
"""
156+
Adds a storage to the list of favorite storages.
157+
"""
158+
url = '/storage/{0}/favorite'.format(storage)
159+
return self.post_request(url)
160+
161+
def remove_storage_from_favorites(self, storage):
162+
"""
163+
Removes a storage from the list of favorite storages.
164+
"""
165+
url = '/storage/{0}/favorite'.format(storage)
166+
return self.request('DELETE', url)

0 commit comments

Comments
 (0)