11from io import BytesIO
2- from test .integration .conftest import get_region , get_regions
2+ from test .integration .conftest import get_regions
33from test .integration .helpers import get_test_label
44
55import polling
66import pytest
77
8+ from linode_api4 import LinodeClient
89from 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" )
1240def 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 ,
0 commit comments