Merge pull request #1182 from mikegrima/s3bug
Fixed bug in S3 put_bucket_tagging. Closes #1181.
This commit is contained in:
commit
84e4f1ff92
@ -780,8 +780,13 @@ class ResponseObject(_TemplateEnvironmentMixin):
|
|||||||
tags = []
|
tags = []
|
||||||
# Optional if no tags are being sent:
|
# Optional if no tags are being sent:
|
||||||
if parsed_xml['Tagging'].get('TagSet'):
|
if parsed_xml['Tagging'].get('TagSet'):
|
||||||
for tag in parsed_xml['Tagging']['TagSet']['Tag']:
|
# If there is only 1 tag, then it's not a list:
|
||||||
tags.append(FakeTag(tag['Key'], tag['Value']))
|
if not isinstance(parsed_xml['Tagging']['TagSet']['Tag'], list):
|
||||||
|
tags.append(FakeTag(parsed_xml['Tagging']['TagSet']['Tag']['Key'],
|
||||||
|
parsed_xml['Tagging']['TagSet']['Tag']['Value']))
|
||||||
|
else:
|
||||||
|
for tag in parsed_xml['Tagging']['TagSet']['Tag']:
|
||||||
|
tags.append(FakeTag(tag['Key'], tag['Value']))
|
||||||
|
|
||||||
tag_set = FakeTagSet(tags)
|
tag_set = FakeTagSet(tags)
|
||||||
tagging = FakeTagging(tag_set)
|
tagging = FakeTagging(tag_set)
|
||||||
|
@ -1441,6 +1441,19 @@ def test_boto3_put_bucket_tagging():
|
|||||||
bucket_name = "mybucket"
|
bucket_name = "mybucket"
|
||||||
s3.create_bucket(Bucket=bucket_name)
|
s3.create_bucket(Bucket=bucket_name)
|
||||||
|
|
||||||
|
# With 1 tag:
|
||||||
|
resp = s3.put_bucket_tagging(Bucket=bucket_name,
|
||||||
|
Tagging={
|
||||||
|
"TagSet": [
|
||||||
|
{
|
||||||
|
"Key": "TagOne",
|
||||||
|
"Value": "ValueOne"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
resp['ResponseMetadata']['HTTPStatusCode'].should.equal(200)
|
||||||
|
|
||||||
|
# With multiple tags:
|
||||||
resp = s3.put_bucket_tagging(Bucket=bucket_name,
|
resp = s3.put_bucket_tagging(Bucket=bucket_name,
|
||||||
Tagging={
|
Tagging={
|
||||||
"TagSet": [
|
"TagSet": [
|
||||||
|
Loading…
Reference in New Issue
Block a user