1- import logging
2- import sys
31import unittest
42from scaleway .vpc .v2 import VpcV2API
53from scaleway_core .api import ScalewayException
64from scaleway_core .client import Client
75from scaleway_core .utils import random_name
86
9- logger = logging .getLogger ()
10- logger .level = logging .DEBUG
11- stream_handler = logging .StreamHandler (sys .stdout )
12- logger .addHandler (stream_handler )
13-
147region = "fr-par"
158tags = ["sdk-python" , "regression-test" ]
169
@@ -31,17 +24,14 @@ def setUpClass(self):
3124 project_id = self .project_id ,
3225 name = random_name ("vpc-test-sdk-python" ),
3326 )
34- logger .info (f"✅ VPC { self ._vpc .id } has been created" )
3527
3628 @classmethod
3729 def tearDownClass (self ):
3830 for pn in self ._pns_to_cleanup :
3931 self .vpcAPI .delete_private_network (private_network_id = pn .id )
40- logger .info (f"🧹 Deleted Private Network { pn .id } " )
4132
4233 if self ._vpc is not None :
4334 self .vpcAPI .delete_vpc (vpc_id = self ._vpc .id , region = self .region )
44- logger .info (f"🧹 Deleted VPC { self ._vpc .id } " )
4535
4636 def test_delete_vpc (self ):
4737 vpc = self .vpcAPI .create_vpc (
@@ -50,20 +40,17 @@ def test_delete_vpc(self):
5040 project_id = self .project_id ,
5141 name = random_name ("vpc-test-sdk-python" ),
5242 )
53- logger . info ( f"✅ VPC { vpc . id } has been created" )
43+
5444 self .assertIsNotNone (vpc .id )
5545 self .assertEqual (vpc .region , self .region )
5646
5747 self .vpcAPI .delete_vpc (vpc_id = vpc .id )
58- logger .info (f"🗑️ VPC { vpc .id } deletion requested" )
5948
6049 with self .assertRaises (ScalewayException ):
6150 self .vpcAPI .get_vpc (vpc_id = vpc .id )
62- logger .info (f"✅ VPC { vpc .id } has been deleted successfully" )
6351
6452 def test_list_vpcs (self ):
6553 vpcs = self .vpcAPI .list_vp_cs (region = self .region ).vpcs
66- logger .info (f"🔎 Listed { len (vpcs )} VPC(s) in region: { self .region } " )
6754 self .assertIsInstance (vpcs , list )
6855
6956 def test_create_private_network (self ):
@@ -75,29 +62,26 @@ def test_create_private_network(self):
7562 name = random_name (f"pn-{ i } " ),
7663 )
7764 self ._pns_to_cleanup .append (pn )
78- logger . info ( f"✅ PN { i + 1 } /5: { pn . id } created in VPC { self . _vpc . id } " )
65+
7966 self .assertEqual (pn .vpc_id , self ._vpc .id )
8067
8168 def test_list_private_network (self ):
8269 networks = self .vpcAPI .list_private_networks (region = self .region )
83- logger .info (
84- f"🔎 Listed { networks .total_count } private network(s) in region: { self .region } "
85- )
8670 self .assertIsInstance (networks .private_networks , list )
8771
8872 def test_get_vpc (self ):
8973 vpc = self .vpcAPI .get_vpc (vpc_id = self ._vpc .id , region = self .region )
90- logger . info ( f"📥 Retrieved VPC { vpc . id } " )
74+
9175 self .assertIsNotNone (vpc )
9276 self .assertEqual (self ._vpc .id , vpc .id )
9377
9478 def test_update_vpc (self ):
9579 vpc = self .vpcAPI .update_vpc (vpc_id = self ._vpc .id , tags = tags )
96- logger . info ( f"🛠️ Updated VPC { vpc . id } with tags: { tags } " )
80+
9781 self .assertEqual (vpc .tags , tags )
9882 self .assertEqual (self ._vpc .id , vpc .id )
9983
10084 def test_list_vpc_all (self ):
10185 vpcs = self .vpcAPI .list_vp_cs_all ()
102- logger . info ( f"📥 Retrieved total of { len ( vpcs ) } VPC(s) across all regions" )
86+
10387 self .assertIsInstance (vpcs , list )
0 commit comments