3232)
3333from linode_api4 .errors import ApiError
3434from linode_api4 .linode_client import LinodeClient , MonitorClient
35- from linode_api4 .objects import Region
35+ from linode_api4 .objects import Capability , Region
3636
3737ENV_TOKEN_NAME = "LINODE_TOKEN"
3838ENV_API_URL_NAME = "LINODE_API_URL"
4242SKIP_E2E_FIREWALL = "SKIP_E2E_FIREWALL"
4343
4444ALL_ACCOUNT_AVAILABILITIES = {
45- "Linodes" ,
46- "NodeBalancers" ,
47- "Block Storage" ,
48- "Kubernetes" ,
45+ Capability . linodes ,
46+ Capability . nodebalancers ,
47+ Capability . block_storage ,
48+ Capability . lke ,
4949}
5050
5151logger = logging .getLogger (__name__ )
@@ -61,7 +61,7 @@ def get_api_url():
6161
6262def get_regions (
6363 client : LinodeClient ,
64- capabilities : Optional [Set [str ]] = None ,
64+ capabilities : Optional [Set [Capability ]] = None ,
6565 site_type : Optional [str ] = None ,
6666):
6767 region_override = os .environ .get (ENV_REGION_OVERRIDE )
@@ -115,7 +115,9 @@ def get_regions(
115115
116116
117117def get_region (
118- client : LinodeClient , capabilities : Set [str ] = None , site_type : str = "core"
118+ client : LinodeClient ,
119+ capabilities : Optional [Set [Capability ]] = None ,
120+ site_type : str = "core" ,
119121):
120122 return random .choice (get_regions (client , capabilities , site_type ))
121123
@@ -223,7 +225,11 @@ def create_inbound_rule(ipv4_address, ipv6_address):
223225def create_linode (test_linode_client , e2e_test_firewall ):
224226 client = test_linode_client
225227
226- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
228+ region = get_region (
229+ client ,
230+ {Capability .linodes , Capability .firewall },
231+ site_type = "core" ,
232+ )
227233 label = get_test_label (length = 8 )
228234
229235 linode_instance = client .linode .instance_create (
@@ -244,7 +250,11 @@ def create_linode(test_linode_client, e2e_test_firewall):
244250def create_linode_for_pass_reset (test_linode_client , e2e_test_firewall ):
245251 client = test_linode_client
246252
247- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
253+ region = get_region (
254+ client ,
255+ {Capability .linodes , Capability .firewall },
256+ site_type = "core" ,
257+ )
248258 label = get_test_label (length = 8 )
249259 password = "aComplex@Password123"
250260
@@ -337,7 +347,11 @@ def get_domain_status():
337347@pytest .fixture (scope = "session" )
338348def test_volume (test_linode_client ):
339349 client = test_linode_client
340- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
350+ region = get_region (
351+ client ,
352+ {Capability .linodes , Capability .firewall },
353+ site_type = "core" ,
354+ )
341355 label = get_test_label (length = 8 )
342356
343357 volume = client .volume_create (label = label , region = region )
@@ -356,7 +370,7 @@ def get_volume_status():
356370@pytest .fixture (scope = "session" )
357371def test_volume_with_encryption (test_linode_client ):
358372 client = test_linode_client
359- region = get_region (client , {"Block Storage Encryption" })
373+ region = get_region (client , {Capability . blockstorage_encryption })
360374 label = get_test_label (length = 8 )
361375
362376 volume = client .volume_create (
@@ -388,7 +402,8 @@ def test_nodebalancer(test_linode_client):
388402 label = get_test_label (length = 8 )
389403
390404 nodebalancer = client .nodebalancer_create (
391- region = get_region (client , capabilities = {"NodeBalancers" }), label = label
405+ region = get_region (client , capabilities = {Capability .nodebalancers }),
406+ label = label ,
392407 )
393408
394409 yield nodebalancer
@@ -475,11 +490,11 @@ def create_vpc(test_linode_client):
475490 region = get_region (
476491 test_linode_client ,
477492 {
478- "VPCs" ,
479- "VPC IPv6 Stack" ,
480- "Linode Interfaces" ,
481- "Custom VPC IPv4 Ranges" ,
482- "Linodes" ,
493+ Capability . vpcs ,
494+ Capability . vpc_ipv6_stack ,
495+ Capability . linode_interfaces ,
496+ Capability . vpc_custom_ipv4_ranges ,
497+ Capability . linodes ,
483498 },
484499 ),
485500 description = "test description" ,
@@ -497,7 +512,12 @@ def create_vpc_with_rdma_type(test_linode_client):
497512
498513 # GPUDirect RDMA capability not available for now
499514 region = get_region (
500- test_linode_client , {"VPCs" , "VPC IPv6 Stack" , "Linode Interfaces" }
515+ test_linode_client ,
516+ {
517+ Capability .vpcs ,
518+ Capability .vpc_ipv6_stack ,
519+ Capability .linode_interfaces ,
520+ },
501521 )
502522
503523 vpc = client .vpcs .create (
@@ -567,7 +587,10 @@ def create_vpc_with_ipv4(test_linode_client):
567587
568588 vpc = client .vpcs .create (
569589 label = get_test_label (length = 10 ),
570- region = get_region (client , {"VPCs" , "Custom VPC IPv4 Ranges" }),
590+ region = get_region (
591+ client ,
592+ {Capability .vpcs , Capability .vpc_custom_ipv4_ranges },
593+ ),
571594 description = "integration test vpc with ipv4" ,
572595 ipv4 = [{"range" : "10.0.0.0/8" }],
573596 )
@@ -587,13 +610,13 @@ def create_multiple_vpcs(test_linode_client):
587610
588611 vpc_1 = client .vpcs .create (
589612 label ,
590- get_region (test_linode_client , {"VPCs" }),
613+ get_region (test_linode_client , {Capability . vpcs }),
591614 description = "test description" ,
592615 )
593616
594617 vpc_2 = client .vpcs .create (
595618 label_2 ,
596- get_region (test_linode_client , {"VPCs" }),
619+ get_region (test_linode_client , {Capability . vpcs }),
597620 description = "test description" ,
598621 )
599622
@@ -612,7 +635,7 @@ def create_placement_group(test_linode_client):
612635
613636 pg = client .placement .group_create (
614637 label ,
615- get_region (test_linode_client , {"Placement Group" }),
638+ get_region (test_linode_client , {Capability . placement_group }),
616639 PlacementGroupType .anti_affinity_local ,
617640 PlacementGroupPolicy .flexible ,
618641 )
@@ -652,7 +675,11 @@ def pytest_configure(config):
652675@pytest .fixture (scope = "session" )
653676def linode_for_vlan_tests (test_linode_client , e2e_test_firewall ):
654677 client = test_linode_client
655- region = get_region (client , {"Linodes" , "Vlans" }, site_type = "core" )
678+ region = get_region (
679+ client ,
680+ {Capability .linodes , Capability .vlans },
681+ site_type = "core" ,
682+ )
656683 label = get_test_label (length = 8 )
657684
658685 linode_instance = client .linode .instance_create (
@@ -811,7 +838,11 @@ def test_monitor_client(get_monitor_token_for_db_entities):
811838@pytest .fixture
812839def create_reserved_ip (test_linode_client ):
813840 client = test_linode_client
814- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
841+ region = get_region (
842+ client ,
843+ {Capability .linodes , Capability .firewall },
844+ site_type = "core" ,
845+ )
815846 reserved_ip = client .networking .reserved_ip_create (
816847 region = region , tags = ["test" ]
817848 )
0 commit comments