Skip to content

Commit 37d9e11

Browse files
authored
Fix volumes client, server should be instance of BoundVolume (#36)
1 parent 07caaf4 commit 37d9e11

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

hcloud/volumes/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ def __init__(self, client, data, complete=True):
1414
location = data.get("location")
1515
if location is not None:
1616
data['location'] = BoundLocation(client._client.locations, location)
17+
18+
from hcloud.servers.client import BoundServer
19+
server = data.get("server")
20+
if server is not None:
21+
data['server'] = BoundServer(client._client.servers, {"id": server}, complete=False)
1722
super(BoundVolume, self).__init__(client, data, complete)
1823

1924
def get_actions_list(self, status=None, sort=None, page=None, per_page=None):

tests/unit/volumes/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def test_bound_volume_init(self, volume_response):
2626
assert bound_volume.id == 1
2727
assert bound_volume.created == isoparse("2016-01-30T23:50:11+00:00")
2828
assert bound_volume.name == "database-storage"
29-
assert bound_volume.server == 12
29+
assert isinstance(bound_volume.server, BoundServer)
30+
assert bound_volume.server.id == 12
3031
assert bound_volume.size == 42
3132
assert bound_volume.linux_device == "/dev/disk/by-id/scsi-0HC_Volume_4711"
3233
assert bound_volume.protection == {"delete": False}

0 commit comments

Comments
 (0)