<s> import aliyun . ecs . connection <EOL> import aliyun . slb . connection <EOL> import unittest <EOL> class EcsReadOnlyTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . c = aliyun . ecs . connection . EcsConnection ( '<STR_LIT>' ) <EOL> def testRegions ( self ) : <EOL> regions = self . c . get_all_regions ( ) <EOL> regionids = self . c . get_all_region_ids ( ) <EOL> self . assertEqual ( [ r . region_id for r in regions ] , regionids ) <EOL> def testZones ( self ) : <EOL> zones = self . c . get_all_zones ( ) <EOL> zoneids = self . c . get_all_zone_ids ( ) <EOL> self . assertEqual ( [ z . zone_id for z in zones ] , zoneids ) <EOL> def testClusters ( self ) : <EOL> clusters = self . c . get_all_clusters ( ) <EOL> self . assertTrue ( len ( clusters ) > <NUM_LIT:0> ) <EOL> def testInstances ( self ) : <EOL> instances = self . c . get_all_instance_status ( ) <EOL> instanceids = self . c . get_all_instance_ids ( ) <EOL> self . assertEqual ( [ i . instance_id for i in instances ] , instanceids ) <EOL> inst = self . c . get_instance ( instanceids . pop ( ) ) <EOL> self . assertTrue ( inst is not None ) <EOL> def testInstancesInZone ( self ) : <EOL> zones = self . c . get_all_zones ( ) <EOL> zone_id = zones . pop ( ) . zone_id <EOL> instances = self . c . get_all_instances ( zone_id ) <EOL> self . assertEqual ( instances . pop ( ) . zone_id , zone_id ) <EOL> def testDescribeDisks ( self ) : <EOL> disks = self . c . describe_disks ( ) <EOL> self . assertTrue ( len ( disks ) > <NUM_LIT:0> ) <EOL> def testDescribeSnapshots ( self ) : <EOL> iid = self . c . get_all_instance_ids ( ) . pop ( ) <EOL> disk = self . c . describe_instance_disks ( iid ) . pop ( ) <EOL> snaps = self . c . describe_snapshots ( iid , disk ) <EOL> if len ( snaps ) > <NUM_LIT:0> : <EOL> snap = self . c . describe_snapshot ( snaps . pop ( ) ) <EOL> self . assertTrue ( snap is not None ) <EOL> def testDescribeImages ( self ) : <EOL> imgs = self . c . describe_images ( ) <EOL> self . assertTrue ( len ( imgs ) > <NUM_LIT:0> ) <EOL> def testSecurityGroups ( self ) : <EOL> groups = self . c . describe_security_groups ( ) <EOL> gids = self . c . get_security_group_ids ( ) <EOL> self . assertEqual ( [ g . security_group_id for g in groups ] , gids ) <EOL> group = self . c . get_security_group ( gids . pop ( ) ) <EOL> self . assertTrue ( group is not None ) <EOL> def testAutoSnapshotPolicy ( self ) : <EOL> print self . c . describe_auto_snapshot_policy ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
