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+ "no-osl-1" ,
17+ }
18+
19+
20+ def get_image_upload_regions (client : LinodeClient ):
21+ """
22+ This is necessary because the API does not currently expose
23+ a capability for regions that allow custom image uploads.
24+
25+ In the future, we should remove this if the API exposes a custom images capability or
26+ if all Object Storage regions support custom images.
27+ """
28+
29+ return [
30+ region
31+ for region in get_regions (
32+ client ,
33+ capabilities = {"Linodes" , "Object Storage" },
34+ site_type = "core" ,
35+ )
36+ if region .id not in DISALLOWED_IMAGE_REGIONS
37+ ]
38+
1039
1140@pytest .fixture (scope = "session" )
1241def image_upload_url (test_linode_client ):
1342 label = get_test_label () + "_image"
1443
15- region = get_region (
16- test_linode_client ,
17- capabilities = {"Linodes" , "Object Storage" },
18- site_type = "core" ,
19- )
44+ region = get_image_upload_regions (test_linode_client )[0 ]
2045
2146 test_linode_client .image_create_upload (
2247 label , region .id , "integration test image upload"
@@ -38,9 +63,7 @@ def test_uploaded_image(test_linode_client):
3863
3964 label = get_test_label () + "_image"
4065
41- regions = get_regions (
42- test_linode_client , capabilities = {"Object Storage" }, site_type = "core"
43- )
66+ regions = get_image_upload_regions (test_linode_client )
4467
4568 image = test_linode_client .image_upload (
4669 label ,
0 commit comments