Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit b79dff0

Browse files
committed
Use new destroy_instance
1 parent 55f3456 commit b79dff0

3 files changed

Lines changed: 4 additions & 39 deletions

File tree

packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,11 @@ def set_instance_state(self, instance: Instance, instance_state: str) -> None:
149149

150150
raise CorelliumApiException(msgerr) from e
151151

152-
def destroy_instance(self, instance: Instance) -> None:
152+
async def destroy_instance(self, instance: Instance) -> None:
153153
"""
154154
Delete a virtual instance.
155155
156156
Does not return anything since Corellium's API return a HTTP 204 response.
157157
"""
158-
try:
159-
res = self.req.delete(f"{self.baseurl}/v1/instances/{instance.id}")
160-
data = res.json() if res.status_code != 204 else None
161-
res.raise_for_status()
162-
except requests.exceptions.RequestException as e:
163-
msgerr = data if data is not None else str(e)
164158

165-
raise CorelliumApiException(msgerr) from e
159+
await self.api.v1_delete_instance(instance.id)

packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/corellium/api_test.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from .api import ApiClient
66
from .exceptions import CorelliumApiException
7-
from .types import Device, Instance, Project, Session
7+
from .types import Device, Project, Session
88

99
pytestmark = pytest.mark.anyio
1010

@@ -100,32 +100,3 @@ async def test_create_instance_error(requests_mock, status_code, data, msg):
100100
api.create_instance("my-instance", project, device, "1.1.1", "Critical Application Monitor (Baremetal)")
101101

102102
assert msg in str(e.value)
103-
104-
105-
async def test_destroy_instance_state_ok(requests_mock):
106-
instance = Instance(id="d59db33d-27bd-4b22-878d-49e4758a648e")
107-
108-
requests_mock.delete(f"https://api-host/api/v1/instances/{instance.id}", status_code=204, text="")
109-
api = ApiClient("api-host", "api-token")
110-
api.session = Session("session-token", "2022-03-20T01:50:10.000Z")
111-
api.destroy_instance(instance)
112-
113-
114-
@pytest.mark.parametrize(
115-
"status_code,data,msg",
116-
[
117-
(403, fixture("http/403.json"), "Invalid or missing authorization token"),
118-
(404, fixture("http/get-instance-state-404.json"), "No instance associated with this value"),
119-
],
120-
)
121-
async def test_destroy_instance_error(requests_mock, status_code, data, msg):
122-
instance = Instance(id="d59db33d-27bd-4b22-878d-49e4758a648e")
123-
124-
requests_mock.delete(f"https://api-host/api/v1/instances/{instance.id}", status_code=status_code, text=data)
125-
api = ApiClient("api-host", "api-token")
126-
api.session = Session("session-token", "2022-03-20T01:50:10.000Z")
127-
128-
with pytest.raises(CorelliumApiException) as e:
129-
api.destroy_instance(instance)
130-
131-
assert msg in str(e.value)

packages/jumpstarter-driver-corellium/jumpstarter_driver_corellium/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ async def off(self, destroy: bool = False) -> None:
198198
self.wait_instance(instance, Instance(id=instance.id, state="off"))
199199

200200
if destroy:
201-
self.parent.api.destroy_instance(instance)
201+
await self.parent.api.destroy_instance(instance)
202202
self.wait_instance(instance, None)
203203

204204
@export

0 commit comments

Comments
 (0)