Skip to content

Commit 632307b

Browse files
Various test fixes to unblock upcoming release
1 parent 78ae618 commit 632307b

2 files changed

Lines changed: 40 additions & 13 deletions

File tree

test/integration/models/image/test_image.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
from io import BytesIO
2-
from test.integration.conftest import get_region, get_regions
2+
from test.integration.conftest import get_regions
33
from test.integration.helpers import get_test_label
44

55
import polling
66
import pytest
77

8+
from linode_api4 import LinodeClient
89
from linode_api4.objects import Image
910

11+
DISALLOWED_IMAGE_REGIONS = {
12+
"gb-lon",
13+
"au-mel",
14+
"sg-sin-2",
15+
"jp-tyo-3",
16+
}
17+
18+
19+
def get_image_upload_regions(client: LinodeClient):
20+
"""
21+
This is necessary because the API does not currently expose
22+
a capability for regions that allow custom image uploads.
23+
24+
In the future, we should remove this if the API exposes a custom images capability or
25+
if all Object Storage regions support custom images.
26+
"""
27+
28+
return [
29+
region
30+
for region in get_regions(
31+
client,
32+
capabilities={"Linodes", "Object Storage"},
33+
site_type="core",
34+
)
35+
if region.id not in DISALLOWED_IMAGE_REGIONS
36+
]
37+
1038

1139
@pytest.fixture(scope="session")
1240
def image_upload_url(test_linode_client):
1341
label = get_test_label() + "_image"
1442

15-
region = get_region(
16-
test_linode_client,
17-
capabilities={"Linodes", "Object Storage"},
18-
site_type="core",
19-
)
43+
region = get_image_upload_regions(test_linode_client)[0]
2044

2145
test_linode_client.image_create_upload(
2246
label, region.id, "integration test image upload"
@@ -38,9 +62,7 @@ def test_uploaded_image(test_linode_client):
3862

3963
label = get_test_label() + "_image"
4064

41-
regions = get_regions(
42-
test_linode_client, capabilities={"Object Storage"}, site_type="core"
43-
)
65+
regions = get_image_upload_regions(test_linode_client)
4466

4567
image = test_linode_client.image_upload(
4668
label,

test/integration/models/nodebalancer/test_nodebalancer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ def test_update_nb(test_linode_client, create_nb):
167167
create_nb.id,
168168
)
169169

170-
nb.label = "ThisNewLabel"
170+
new_label = f"{nb.label}-ThisNewLabel"
171+
172+
nb.label = new_label
171173
nb.client_udp_sess_throttle = 5
172174
nb.save()
173175

@@ -176,7 +178,7 @@ def test_update_nb(test_linode_client, create_nb):
176178
create_nb.id,
177179
)
178180

179-
assert "ThisNewLabel" == nb_updated.label
181+
assert new_label == nb_updated.label
180182
assert 5 == nb_updated.client_udp_sess_throttle
181183

182184

@@ -215,7 +217,10 @@ def test_update_nb_node(test_linode_client, create_nb_config):
215217
create_nb_config.nodebalancer_id,
216218
)
217219
node = config.nodes[0]
218-
node.label = "ThisNewLabel"
220+
221+
new_label = f"{node.label}-ThisNewLabel"
222+
223+
node.label = new_label
219224
node.weight = 50
220225
node.mode = "accept"
221226
node.save()
@@ -226,7 +231,7 @@ def test_update_nb_node(test_linode_client, create_nb_config):
226231
(create_nb_config.id, create_nb_config.nodebalancer_id),
227232
)
228233

229-
assert "ThisNewLabel" == node_updated.label
234+
assert new_label == node_updated.label
230235
assert 50 == node_updated.weight
231236
assert "accept" == node_updated.mode
232237

0 commit comments

Comments
 (0)