Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: third_party/gsutil/third_party/boto/tests/unit/ec2/test_spotinstance.py

Issue 1377933002: [catapult] - Copy Telemetry's gsutilz over to third_party. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Rename to gsutil. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/gsutil/third_party/boto/tests/unit/ec2/test_spotinstance.py
diff --git a/third_party/gsutil/third_party/boto/tests/unit/ec2/test_spotinstance.py b/third_party/gsutil/third_party/boto/tests/unit/ec2/test_spotinstance.py
new file mode 100644
index 0000000000000000000000000000000000000000..b4c81caad1ae09833c428fb141ff9c7608c84243
--- /dev/null
+++ b/third_party/gsutil/third_party/boto/tests/unit/ec2/test_spotinstance.py
@@ -0,0 +1,110 @@
+from tests.unit import AWSMockServiceTestCase
+
+from boto.ec2.connection import EC2Connection
+
+
+class TestCancelSpotInstanceRequests(AWSMockServiceTestCase):
+
+ connection_class = EC2Connection
+
+ def default_body(self):
+ return b"""
+ <CancelSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <spotInstanceRequestSet>
+ <item>
+ <spotInstanceRequestId>sir-1a2b3c4d</spotInstanceRequestId>
+ <state>cancelled</state>
+ </item>
+ <item>
+ <spotInstanceRequestId>sir-9f8e7d6c</spotInstanceRequestId>
+ <state>cancelled</state>
+ </item>
+ </spotInstanceRequestSet>
+ </CancelSpotInstanceRequestsResponse>
+ """
+
+ def test_cancel_spot_instance_requests(self):
+ self.set_http_response(status_code=200)
+ response = self.service_connection.cancel_spot_instance_requests(['sir-1a2b3c4d',
+ 'sir-9f8e7d6c'])
+ self.assert_request_parameters({
+ 'Action': 'CancelSpotInstanceRequests',
+ 'SpotInstanceRequestId.1': 'sir-1a2b3c4d',
+ 'SpotInstanceRequestId.2': 'sir-9f8e7d6c'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+ self.assertEqual(len(response), 2)
+ self.assertEqual(response[0].id, 'sir-1a2b3c4d')
+ self.assertEqual(response[0].state, 'cancelled')
+ self.assertEqual(response[1].id, 'sir-9f8e7d6c')
+ self.assertEqual(response[1].state, 'cancelled')
+
+
+class TestGetSpotPriceHistory(AWSMockServiceTestCase):
+
+ connection_class = EC2Connection
+
+ def default_body(self):
+ return b"""
+ <DescribeSpotPriceHistoryResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
+ <requestId>b6c6978c-bd13-4ad7-9bc8-6f0ac9d32bcc</requestId>
+ <spotPriceHistorySet>
+ <item>
+ <instanceType>c3.large</instanceType>
+ <productDescription>Linux/UNIX</productDescription>
+ <spotPrice>0.032000</spotPrice>
+ <timestamp>2013-12-28T12:17:43.000Z</timestamp>
+ <availabilityZone>us-west-2c</availabilityZone>
+ </item>
+ <item>
+ <instanceType>c3.large</instanceType>
+ <productDescription>Windows (Amazon VPC)</productDescription>
+ <spotPrice>0.104000</spotPrice>
+ <timestamp>2013-12-28T07:49:40.000Z</timestamp>
+ <availabilityZone>us-west-2b</availabilityZone>
+ </item>
+ </spotPriceHistorySet>
+ <nextToken>q5GwEl5bMGjKq6YmhpDLJ7hEwyWU54jJC2GQ93n61vZV4s1+fzZ674xzvUlTihrl</nextToken>
+ </DescribeSpotPriceHistoryResponse>
+ """
+
+ def test_get_spot_price_history(self):
+ self.set_http_response(status_code=200)
+ response = self.service_connection.get_spot_price_history(
+ instance_type='c3.large')
+ self.assert_request_parameters({
+ 'Action': 'DescribeSpotPriceHistory',
+ 'InstanceType': 'c3.large'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+ self.assertEqual(len(response), 2)
+ self.assertEqual(response.next_token,
+ 'q5GwEl5bMGjKq6YmhpDLJ7hEwyWU54jJC2GQ93n61vZV4s1+fzZ674xzvUlTihrl')
+ self.assertEqual(response.nextToken,
+ 'q5GwEl5bMGjKq6YmhpDLJ7hEwyWU54jJC2GQ93n61vZV4s1+fzZ674xzvUlTihrl')
+ self.assertEqual(response[0].instance_type, 'c3.large')
+ self.assertEqual(response[0].availability_zone, 'us-west-2c')
+ self.assertEqual(response[1].instance_type, 'c3.large')
+ self.assertEqual(response[1].availability_zone, 'us-west-2b')
+
+ response = self.service_connection.get_spot_price_history(
+ filters={'instance-type': 'c3.large'})
+ self.assert_request_parameters({
+ 'Action': 'DescribeSpotPriceHistory',
+ 'Filter.1.Name': 'instance-type',
+ 'Filter.1.Value.1': 'c3.large'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
+ response = self.service_connection.get_spot_price_history(
+ next_token='foobar')
+ self.assert_request_parameters({
+ 'Action': 'DescribeSpotPriceHistory',
+ 'NextToken': 'foobar'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])

Powered by Google App Engine
This is Rietveld 408576698