diff --git a/moto/rds2/responses.py b/moto/rds2/responses.py index 8b483844f..54a132027 100644 --- a/moto/rds2/responses.py +++ b/moto/rds2/responses.py @@ -14,7 +14,7 @@ class RDS2Response(BaseResponse): return rds2_backends[self.region] def _get_db_kwargs(self): - return { + args = { "auto_minor_version_upgrade": self._get_param('AutoMinorVersionUpgrade'), "allocated_storage": self._get_int_param('AllocatedStorage'), "availability_zone": self._get_param("AvailabilityZone"), @@ -39,7 +39,16 @@ class RDS2Response(BaseResponse): "security_groups": self._get_multi_param('DBSecurityGroups.member'), "storage_type": self._get_param("StorageType"), # VpcSecurityGroupIds.member.N + "tags": [] } + count = 1 + while self._get_param('Tags.member.{}.Key'.format(count)): + args["tags"].append({ + "Key": self._get_param('Tags.member.{}.Key'.format(count)), + "Value": self._get_param('Tags.member.{}.Value'.format(count)) + }) + count += 1 + return args def _get_db_replica_kwargs(self): return { @@ -414,9 +423,10 @@ LIST_TAGS_FOR_RESOURCE_TEMPLATE = \ {"TagList": [ {%- for tag in tags -%} {%- if loop.index != 1 -%},{%- endif -%} - {%- for key in tag -%} - {"Value": "{{ tag[key] }}", "Key": "{{ key }}"} - {%- endfor -%} + { + "Key": "{{ tag['Key'] }}", + "Value": "{{ tag['Value'] }}" + } {%- endfor -%} ]}, "ResponseMetadata": { diff --git a/tests/test_rds2/test_rds2.py b/tests/test_rds2/test_rds2.py index 8fa6c91d0..0b72b8ed7 100644 --- a/tests/test_rds2/test_rds2.py +++ b/tests/test_rds2/test_rds2.py @@ -277,15 +277,19 @@ def test_list_tags(): conn = boto.rds2.connect_to_region("us-west-2") result = conn.list_tags_for_resource('arn:aws:rds:us-west-2:1234567890:db:foo') result['ListTagsForResourceResponse']['ListTagsForResourceResult']['TagList'].should.equal([]) - conn.create_db_instance(db_instance_identifier='db-master-1', + conn.create_db_instance(db_instance_identifier='db-with-tags', allocated_storage=10, engine='postgres', db_instance_class='db.m1.small', master_username='root', master_user_password='hunter2', db_security_groups=["my_sg"], - tags=[{'Key': 'foo', 'Value': 'bar'}]) - result = conn.list_tags_for_resource('arn:aws:rds:us-west-2:1234567890:db:db-master-1') + tags=[('foo', 'bar'), ('foo1', 'bar1')]) + result = conn.list_tags_for_resource('arn:aws:rds:us-west-2:1234567890:db:db-with-tags') + result['ListTagsForResourceResponse']['ListTagsForResourceResult']['TagList'].should.equal([{'Value': 'bar', + 'Key': 'foo'}, + {'Value': 'bar1', + 'Key': 'foo1'}]) #@disable_on_py3() #@mock_rds2