Skip to content

Commit 5eb4445

Browse files
committed
fix(instance): update tests and add update-goldens rule
1 parent d6c1fad commit 5eb4445

File tree

3 files changed

+64
-57
lines changed

3 files changed

+64
-57
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ test:
5858
poetry run pytest -v; \
5959
done
6060

61+
update-goldens:
62+
PYTHON_UPDATE_CASSETTES=true $(MAKE) test
63+
6164
publish: install-dependencies
6265
for lib in $(LIBRARIES); do \
6366
cd ${WORKDIR}/$$lib && \

scaleway/scaleway/instance/v1/custom_api.py

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
from .api import InstanceV1API
1010
from .custom_marshalling import marshal_GetServerUserDataRequest
1111
from .custom_types import GetServerUserDataRequest, GetAllServerUserDataResponse
12+
from .types import (
13+
VolumeServerTemplate,
14+
BootType,
15+
CreateServerResponse,
16+
)
1217

1318
max_retry = 10
1419
interval = 0.01
@@ -148,61 +153,61 @@ def wait_instance_server(self, server_id: str, zone: ScwZone) -> GetServerRespon
148153
)
149154

150155
def create_instance_server(
151-
self,
152-
*,
153-
zone: Optional[ScwZone] = None,
154-
commercial_type: str,
155-
name: Optional[str] = None,
156-
dynamic_ip_required: Optional[bool] = None,
157-
routed_ip_enabled: Optional[bool] = None,
158-
image: Optional[str] = None,
159-
volumes: Optional[dict[str, VolumeServerTemplate]] = None,
160-
enable_ipv6: Optional[bool] = None,
161-
protected: bool = False,
162-
public_ip: Optional[str] = None,
163-
public_ips: Optional[list[str]] = None,
164-
boot_type: Optional[BootType] = None,
165-
organization: Optional[str] = None,
166-
project: Optional[str] = None,
167-
tags: Optional[list[str]] = None,
168-
security_group: Optional[str] = None,
169-
placement_group: Optional[str] = None,
170-
admin_password_encryption_ssh_key_id: Optional[str] = None,
156+
self,
157+
*,
158+
zone: Optional[ScwZone] = None,
159+
commercial_type: str,
160+
name: Optional[str] = None,
161+
dynamic_ip_required: Optional[bool] = None,
162+
routed_ip_enabled: Optional[bool] = None,
163+
image: Optional[str] = None,
164+
volumes: Optional[dict[str, VolumeServerTemplate]] = None,
165+
enable_ipv6: Optional[bool] = None,
166+
protected: bool = False,
167+
public_ip: Optional[str] = None,
168+
public_ips: Optional[list[str]] = None,
169+
boot_type: Optional[BootType] = None,
170+
organization: Optional[str] = None,
171+
project: Optional[str] = None,
172+
tags: Optional[list[str]] = None,
173+
security_group: Optional[str] = None,
174+
placement_group: Optional[str] = None,
175+
admin_password_encryption_ssh_key_id: Optional[str] = None,
171176
) -> CreateServerResponse:
172177
"""
173-
Create an Instance.
174-
Create a new Instance of the specified commercial type in the specified zone. Pay attention to the volumes parameter, which takes an object which can be used in different ways to achieve different behaviors.
175-
Get more information in the [Technical Information](#technical-information) section of the introduction.
176-
:param zone: Zone to target. If none is passed will use default zone from the config.
177-
:param commercial_type: Define the Instance commercial type (i.e. GP1-S).
178-
:param name: Instance name.
179-
:param dynamic_ip_required: By default, `dynamic_ip_required` is true, a dynamic ip is attached to the instance (if no flexible ip is already attached).
180-
:param routed_ip_enabled: If true, configure the Instance so it uses the new routed IP mode.
181-
:param image: Instance image ID or label.
182-
:param volumes: Volumes attached to the server.
183-
:param enable_ipv6: True if IPv6 is enabled on the server (deprecated and always `False` when `routed_ip_enabled` is `True`).
184-
:param protected: True to activate server protection option.
185-
:param public_ip: ID of the reserved IP to attach to the Instance.
186-
:param public_ips: A list of reserved IP IDs to attach to the Instance.
187-
:param boot_type: Boot type to use.
188-
:param organization: Instance Organization ID.
189-
One-Of ('project_identifier'): at most one of 'project', 'organization' could be set.
190-
:param project: Instance Project ID.
191-
One-Of ('project_identifier'): at most one of 'project', 'organization' could be set.
192-
:param tags: Instance tags.
193-
:param security_group: Security group ID.
194-
:param placement_group: Placement group ID if Instance must be part of a placement group.
195-
:param admin_password_encryption_ssh_key_id: The public_key value of this key is used to encrypt the admin password.
196-
:return: :class:`CreateServerResponse <CreateServerResponse>`
197-
198-
Usage:
199-
::
200-
201-
result = api.create_instance_server(
202-
commercial_type="example",
203-
protected=False,
204-
)
205-
"""
178+
Create an Instance.
179+
Create a new Instance of the specified commercial type in the specified zone. Pay attention to the volumes parameter, which takes an object which can be used in different ways to achieve different behaviors.
180+
Get more information in the [Technical Information](#technical-information) section of the introduction.
181+
:param zone: Zone to target. If none is passed will use default zone from the config.
182+
:param commercial_type: Define the Instance commercial type (i.e. GP1-S).
183+
:param name: Instance name.
184+
:param dynamic_ip_required: By default, `dynamic_ip_required` is true, a dynamic ip is attached to the instance (if no flexible ip is already attached).
185+
:param routed_ip_enabled: If true, configure the Instance so it uses the new routed IP mode.
186+
:param image: Instance image ID or label.
187+
:param volumes: Volumes attached to the server.
188+
:param enable_ipv6: True if IPv6 is enabled on the server (deprecated and always `False` when `routed_ip_enabled` is `True`).
189+
:param protected: True to activate server protection option.
190+
:param public_ip: ID of the reserved IP to attach to the Instance.
191+
:param public_ips: A list of reserved IP IDs to attach to the Instance.
192+
:param boot_type: Boot type to use.
193+
:param organization: Instance Organization ID.
194+
One-Of ('project_identifier'): at most one of 'project', 'organization' could be set.
195+
:param project: Instance Project ID.
196+
One-Of ('project_identifier'): at most one of 'project', 'organization' could be set.
197+
:param tags: Instance tags.
198+
:param security_group: Security group ID.
199+
:param placement_group: Placement group ID if Instance must be part of a placement group.
200+
:param admin_password_encryption_ssh_key_id: The public_key value of this key is used to encrypt the admin password.
201+
:return: :class:`CreateServerResponse <CreateServerResponse>`
202+
203+
Usage:
204+
::
205+
206+
result = api.create_instance_server(
207+
commercial_type="example",
208+
protected=False,
209+
)
210+
"""
206211

207212
payload = {
208213
"zone": zone,
@@ -227,6 +232,4 @@ def create_instance_server(
227232

228233
clean_payload = {k: v for k, v in payload.items() if v is not None}
229234

230-
response = self._create_server(**clean_payload)
231-
232-
return response
235+
return self._create_server(**clean_payload)

scaleway/scaleway/instance/v1/tests/test_custom_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from tests.utils import initialize_client_test
88
from vcr_config import scw_vcr
99

10+
1011
server_name = "test-sdk-python-fixture"
1112
server_name_extra = "test-sdk-python-extra"
1213
max_retry = 10
@@ -26,7 +27,7 @@ def instance_api() -> InstanceUtilsV1API:
2627
@pytest.fixture(scope="module")
2728
@scw_vcr.use_cassette
2829
def server(instance_api: InstanceUtilsV1API) -> Generator[Server, Any, None]:
29-
instance = instance_api._create_server(
30+
instance = instance_api.create_instance_server(
3031
commercial_type=commercial_type,
3132
zone=zone,
3233
name=server_name,

0 commit comments

Comments
 (0)