71
71
ec2 = client.EC2Client(creds=creds)
72
72
self.assertEqual(creds, ec2.creds)
74
def test_describe_availability_zones_single(self):
75
class StubQuery(object):
76
def __init__(stub, action, creds, endpoint, other_params):
77
self.assertEqual(action, "DescribeAvailabilityZones")
78
self.assertEqual(creds.access_key, "foo")
79
self.assertEqual(creds.secret_key, "bar")
81
{"ZoneName.1": "us-east-1a"},
85
payload.sample_describe_availability_zones_single_result)
87
def check_parsed_availability_zone(results):
88
self.assertEquals(len(results), 1)
90
self.assertEquals(zone.name, "us-east-1a")
91
self.assertEquals(zone.state, "available")
94
creds = AWSCredentials("foo", "bar")
95
ec2 = client.EC2Client(creds, query_factory=StubQuery)
96
d = ec2.describe_availability_zones(["us-east-1a"])
97
d.addCallback(check_parsed_availability_zone)
100
def test_describe_availability_zones_multiple(self):
101
class StubQuery(object):
102
def __init__(stub, action, creds, endpoint, other_params):
103
self.assertEqual(action, "DescribeAvailabilityZones")
104
self.assertEqual(creds.access_key, "foo")
105
self.assertEqual(creds.secret_key, "bar")
108
payload.sample_describe_availability_zones_multiple_results)
110
def check_parsed_availability_zones(results):
111
self.assertEquals(len(results), 3)
112
self.assertEquals(results[0].name, "us-east-1a")
113
self.assertEquals(results[0].state, "available")
114
self.assertEquals(results[1].name, "us-east-1b")
115
self.assertEquals(results[1].state, "available")
116
self.assertEquals(results[2].name, "us-east-1c")
117
self.assertEquals(results[2].state, "available")
119
creds = AWSCredentials("foo", "bar")
120
ec2 = client.EC2Client(creds, query_factory=StubQuery)
121
d = ec2.describe_availability_zones()
122
d.addCallback(check_parsed_availability_zones)
75
126
class EC2ClientInstancesTestCase(TXAWSTestCase):