Skip to content

Commit f331a99

Browse files
author
Adam Heinz
committed
Updated resize to allow Type class, includes test
1 parent c63cc92 commit f331a99

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

linode_api4/objects/linode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ def reboot(self):
349349
return True
350350

351351
def resize(self, new_type):
352+
new_type = new_type.id if issubclass(type(new_type), Base) else new_type
352353
resp = self._client.post("{}/resize".format(Instance.api_endpoint), model=self, data={"type": new_type})
353354

354355
if 'error' in resp:

test/objects/linode_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ def test_resize(self):
172172
self.assertEqual(m.call_url, '/linode/instances/123/resize')
173173
self.assertEqual(m.call_data, {'type': 'g6-standard-1'})
174174

175+
def test_resize_with_class(self):
176+
"""
177+
Tests that you can submit a correct resize api request with a Base class type
178+
"""
179+
linode = Instance(self.client, 123)
180+
ltype = Type(self.client, 'g6-standard-2')
181+
result = {}
182+
183+
with self.mock_post(result) as m:
184+
linode.resize(new_type=ltype)
185+
self.assertEqual(m.call_url, '/linode/instances/123/resize')
186+
self.assertEqual(m.call_data, {'type': 'g6-standard-2'})
187+
175188
def test_boot_with_config(self):
176189
"""
177190
Tests that you can submit a correct boot with a config api request

0 commit comments

Comments
 (0)