3333)
3434from linode_api4 .errors import ApiError
3535from linode_api4 .linode_client import LinodeClient , MonitorClient
36- from linode_api4 .objects import Region
36+ from linode_api4 .objects import Capability , Region
3737
3838ENV_TOKEN_NAME = "LINODE_TOKEN"
3939ENV_API_URL_NAME = "LINODE_API_URL"
4343SKIP_E2E_FIREWALL = "SKIP_E2E_FIREWALL"
4444
4545ALL_ACCOUNT_AVAILABILITIES = {
46- "Linodes" ,
47- "NodeBalancers" ,
48- "Block Storage" ,
49- "Kubernetes" ,
46+ Capability . linodes ,
47+ Capability . nodebalancers ,
48+ Capability . block_storage ,
49+ Capability . lke ,
5050}
5151
5252logger = logging .getLogger (__name__ )
@@ -62,7 +62,7 @@ def get_api_url():
6262
6363def get_regions (
6464 client : LinodeClient ,
65- capabilities : Optional [Set [str ]] = None ,
65+ capabilities : Optional [Set [Capability ]] = None ,
6666 site_type : Optional [str ] = None ,
6767):
6868 region_override = os .environ .get (ENV_REGION_OVERRIDE )
@@ -116,7 +116,9 @@ def get_regions(
116116
117117
118118def get_region (
119- client : LinodeClient , capabilities : Set [str ] = None , site_type : str = "core"
119+ client : LinodeClient ,
120+ capabilities : Optional [Set [Capability ]] = None ,
121+ site_type : str = "core" ,
120122):
121123 return random .choice (get_regions (client , capabilities , site_type ))
122124
@@ -224,7 +226,11 @@ def create_inbound_rule(ipv4_address, ipv6_address):
224226def create_linode (test_linode_client , e2e_test_firewall ):
225227 client = test_linode_client
226228
227- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
229+ region = get_region (
230+ client ,
231+ {Capability .linodes , Capability .firewall },
232+ site_type = "core" ,
233+ )
228234 label = get_test_label (length = 8 )
229235
230236 linode_instance = client .linode .instance_create (
@@ -245,7 +251,11 @@ def create_linode(test_linode_client, e2e_test_firewall):
245251def create_linode_for_pass_reset (test_linode_client , e2e_test_firewall ):
246252 client = test_linode_client
247253
248- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
254+ region = get_region (
255+ client ,
256+ {Capability .linodes , Capability .firewall },
257+ site_type = "core" ,
258+ )
249259 label = get_test_label (length = 8 )
250260 password = "aComplex@Password123"
251261
@@ -349,7 +359,11 @@ def get_domain_status():
349359@pytest .fixture (scope = "session" )
350360def test_volume (test_linode_client ):
351361 client = test_linode_client
352- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
362+ region = get_region (
363+ client ,
364+ {Capability .linodes , Capability .firewall },
365+ site_type = "core" ,
366+ )
353367 label = get_test_label (length = 8 )
354368
355369 volume = client .volume_create (label = label , region = region )
@@ -368,7 +382,7 @@ def get_volume_status():
368382@pytest .fixture (scope = "session" )
369383def test_volume_with_encryption (test_linode_client ):
370384 client = test_linode_client
371- region = get_region (client , {"Block Storage Encryption" })
385+ region = get_region (client , {Capability . blockstorage_encryption })
372386 label = get_test_label (length = 8 )
373387
374388 volume = client .volume_create (
@@ -400,7 +414,8 @@ def test_nodebalancer(test_linode_client):
400414 label = get_test_label (length = 8 )
401415
402416 nodebalancer = client .nodebalancer_create (
403- region = get_region (client , capabilities = {"NodeBalancers" }), label = label
417+ region = get_region (client , capabilities = {Capability .nodebalancers }),
418+ label = label ,
404419 )
405420
406421 yield nodebalancer
@@ -487,11 +502,11 @@ def create_vpc(test_linode_client):
487502 region = get_region (
488503 test_linode_client ,
489504 {
490- "VPCs" ,
491- "VPC IPv6 Stack" ,
492- "Linode Interfaces" ,
493- "Custom VPC IPv4 Ranges" ,
494- "Linodes" ,
505+ Capability . vpcs ,
506+ Capability . vpc_ipv6_stack ,
507+ Capability . linode_interfaces ,
508+ Capability . vpc_custom_ipv4_ranges ,
509+ Capability . linodes ,
495510 },
496511 ),
497512 description = "test description" ,
@@ -509,7 +524,12 @@ def create_vpc_with_rdma_type(test_linode_client):
509524
510525 # GPUDirect RDMA capability not available for now
511526 region = get_region (
512- test_linode_client , {"VPCs" , "VPC IPv6 Stack" , "Linode Interfaces" }
527+ test_linode_client ,
528+ {
529+ Capability .vpcs ,
530+ Capability .vpc_ipv6_stack ,
531+ Capability .linode_interfaces ,
532+ },
513533 )
514534
515535 vpc = client .vpcs .create (
@@ -579,7 +599,10 @@ def create_vpc_with_ipv4(test_linode_client):
579599
580600 vpc = client .vpcs .create (
581601 label = get_test_label (length = 10 ),
582- region = get_region (client , {"VPCs" , "Custom VPC IPv4 Ranges" }),
602+ region = get_region (
603+ client ,
604+ {Capability .vpcs , Capability .vpc_custom_ipv4_ranges },
605+ ),
583606 description = "integration test vpc with ipv4" ,
584607 ipv4 = [{"range" : "10.0.0.0/8" }],
585608 )
@@ -599,13 +622,13 @@ def create_multiple_vpcs(test_linode_client):
599622
600623 vpc_1 = client .vpcs .create (
601624 label ,
602- get_region (test_linode_client , {"VPCs" }),
625+ get_region (test_linode_client , {Capability . vpcs }),
603626 description = "test description" ,
604627 )
605628
606629 vpc_2 = client .vpcs .create (
607630 label_2 ,
608- get_region (test_linode_client , {"VPCs" }),
631+ get_region (test_linode_client , {Capability . vpcs }),
609632 description = "test description" ,
610633 )
611634
@@ -624,7 +647,7 @@ def create_placement_group(test_linode_client):
624647
625648 pg = client .placement .group_create (
626649 label ,
627- get_region (test_linode_client , {"Placement Group" }),
650+ get_region (test_linode_client , {Capability . placement_group }),
628651 PlacementGroupType .anti_affinity_local ,
629652 PlacementGroupPolicy .flexible ,
630653 )
@@ -664,7 +687,11 @@ def pytest_configure(config):
664687@pytest .fixture (scope = "session" )
665688def linode_for_vlan_tests (test_linode_client , e2e_test_firewall ):
666689 client = test_linode_client
667- region = get_region (client , {"Linodes" , "Vlans" }, site_type = "core" )
690+ region = get_region (
691+ client ,
692+ {Capability .linodes , Capability .vlans },
693+ site_type = "core" ,
694+ )
668695 label = get_test_label (length = 8 )
669696
670697 linode_instance = client .linode .instance_create (
@@ -823,7 +850,11 @@ def test_monitor_client(get_monitor_token_for_db_entities):
823850@pytest .fixture
824851def create_reserved_ip (test_linode_client ):
825852 client = test_linode_client
826- region = get_region (client , {"Linodes" , "Cloud Firewall" }, site_type = "core" )
853+ region = get_region (
854+ client ,
855+ {Capability .linodes , Capability .firewall },
856+ site_type = "core" ,
857+ )
827858 reserved_ip = client .networking .reserved_ip_create (
828859 region = region , tags = ["test" ]
829860 )
0 commit comments