1 Index: boto-2.40.0/boto/ec2/instance.py
2 ===================================================================
3 --- boto-2.40.0.orig/boto/ec2/instance.py
4 +++ boto-2.40.0/boto/ec2/instance.py
5 @@ -631,7 +631,8 @@ class InstanceAttribute(dict):
6 'disableApiTermination',
7 'instanceInitiatedShutdownBehavior',
8 'rootDeviceName', 'blockDeviceMapping', 'sourceDestCheck',
10 + 'groupSet', 'productCodes', 'ebsOptimized',
13 def __init__(self, parent=None):
15 Index: boto-2.40.0/tests/unit/ec2/test_attribute.py
16 ===================================================================
18 +++ boto-2.40.0/tests/unit/ec2/test_attribute.py
20 +from tests.unit import unittest
21 +from tests.compat import mock
23 +from boto.ec2.connection import EC2Connection, Instance
25 +ATTRIBUTE_GET_TRUE_EBSOPTIMIZED_RESPONSE = b"""
26 +<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2014-10-01/">
27 + <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
28 + <instanceId>i-10a64379</instanceId>
32 +</DescribeInstanceAttributeResponse>
35 +ATTRIBUTE_GET_FALSE_EBSOPTIMIZED_RESPONSE = b"""
36 +<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2014-10-01/">
37 + <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
38 + <instanceId>i-10a64379</instanceId>
40 + <value>false</value>
42 +</DescribeInstanceAttributeResponse>
45 +ATTRIBUTE_GET_EMPTY_PRODUCTCODES_RESPONSE = b"""
46 +<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2014-10-01/">
47 + <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
48 + <instanceId>i-10a64379</instanceId>
50 +</DescribeInstanceAttributeResponse>
53 +# Tests to be run on an InstanceAttributes
55 +# (EC2_RESPONSE_STRING, (string_of_attribute_to_test, value) )
57 + (ATTRIBUTE_GET_TRUE_EBSOPTIMIZED_RESPONSE,
58 + ('ebsOptimized', True)),
59 + (ATTRIBUTE_GET_FALSE_EBSOPTIMIZED_RESPONSE,
60 + ('ebsOptimized', False)),
61 + (ATTRIBUTE_GET_EMPTY_PRODUCTCODES_RESPONSE,
62 + ('productCodes', None)),
66 +class TestInstanceAttributes(unittest.TestCase):
67 + """Tests Instance Attributes."""
68 + def _setup_mock(self):
69 + """Sets up a mock ec2 request.
70 + Returns: response, ec2 connection and Instance
72 + mock_response = mock.Mock()
73 + mock_response.status = 200
74 + ec2 = EC2Connection(aws_access_key_id='aws_access_key_id',
75 + aws_secret_access_key='aws_secret_access_key')
76 + ec2.make_request = mock.Mock(return_value=mock_response)
77 + return mock_response, ec2, Instance(ec2)
79 + def test_instance_get_attributes(self):
80 + """Tests the InstanceAttributes from the EC2 object."""
81 + mock_response, _, instance = self._setup_mock()
83 + for response, attr_test in ATTRIBUTE_TESTS:
84 + mock_response.read.return_value = response
85 + expected_value = dict([attr_test])
86 + actual_value = instance.get_attribute(attr_test[0])
87 + self.assertEqual(expected_value, actual_value)
90 +if __name__ == '__main__':