Merge pull request #2096 from tay-bird/fix-describe-volumes-response-with-no-tags

Fix describe volumes response with no tags
This commit is contained in:
Mike Grima 2019-03-11 13:44:15 -07:00 committed by GitHub
commit fe42309534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 26 deletions

View File

@ -150,6 +150,7 @@ CREATE_VOLUME_RESPONSE = """<CreateVolumeResponse xmlns="http://ec2.amazonaws.co
<availabilityZone>{{ volume.zone.name }}</availabilityZone> <availabilityZone>{{ volume.zone.name }}</availabilityZone>
<status>creating</status> <status>creating</status>
<createTime>{{ volume.create_time}}</createTime> <createTime>{{ volume.create_time}}</createTime>
{% if volume.get_tags() %}
<tagSet> <tagSet>
{% for tag in volume.get_tags() %} {% for tag in volume.get_tags() %}
<item> <item>
@ -160,6 +161,7 @@ CREATE_VOLUME_RESPONSE = """<CreateVolumeResponse xmlns="http://ec2.amazonaws.co
</item> </item>
{% endfor %} {% endfor %}
</tagSet> </tagSet>
{% endif %}
<volumeType>standard</volumeType> <volumeType>standard</volumeType>
</CreateVolumeResponse>""" </CreateVolumeResponse>"""
@ -191,6 +193,7 @@ DESCRIBE_VOLUMES_RESPONSE = """<DescribeVolumesResponse xmlns="http://ec2.amazon
</item> </item>
{% endif %} {% endif %}
</attachmentSet> </attachmentSet>
{% if volume.get_tags() %}
<tagSet> <tagSet>
{% for tag in volume.get_tags() %} {% for tag in volume.get_tags() %}
<item> <item>
@ -201,6 +204,7 @@ DESCRIBE_VOLUMES_RESPONSE = """<DescribeVolumesResponse xmlns="http://ec2.amazon
</item> </item>
{% endfor %} {% endfor %}
</tagSet> </tagSet>
{% endif %}
<volumeType>standard</volumeType> <volumeType>standard</volumeType>
</item> </item>
{% endfor %} {% endfor %}

View File

@ -589,6 +589,18 @@ def test_volume_tag_escaping():
dict(snaps[0].tags).should.equal({'key': '</closed>'}) dict(snaps[0].tags).should.equal({'key': '</closed>'})
@mock_ec2
def test_volume_property_hidden_when_no_tags_exist():
ec2_client = boto3.client('ec2', region_name='us-east-1')
volume_response = ec2_client.create_volume(
Size=10,
AvailabilityZone='us-east-1a'
)
volume_response.get('Tags').should.equal(None)
@freeze_time @freeze_time
@mock_ec2 @mock_ec2
def test_copy_snapshot(): def test_copy_snapshot():