Skip to content

Commit

Permalink
Merge branch 'fix-md5-handler' of git://github.com/garnaat/aws-cli in…
Browse files Browse the repository at this point in the history
…to garnaat-fix-md5-handler
  • Loading branch information
garnaat committed Aug 20, 2013
2 parents 492e282 + ae468f1 commit 1934e84
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/unit/s3/test_put_bucket_tagging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env python
# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
import re
import copy

from tests.unit import BaseAWSCommandParamsTest
import httpretty
import six


# file is gone in python3, so instead IOBase must be used.
# Given this test module is the only place that cares about
# this type check, we do the check directly in this test module.
try:
file_type = file
except NameError:
import io
file_type = io.IOBase


TAGSET = """{"TagSet":[{"Key":"key1","Value":"value1"},{"Key":"key2","Value":"value2"}]}"""


class TestPutBucketTagging(BaseAWSCommandParamsTest):

prefix = 's3api put-bucket-tagging'

def setUp(self):
super(TestPutBucketTagging, self).setUp()
self.payload = None

def _store_params(self, params):
# Copy the params dict without the payload attribute.
self.payload = params['payload']
self.last_params = params.copy()
del self.last_params['payload']
self.last_params = copy.deepcopy(self.last_params)
# There appears to be a bug in httpretty and python3, and we're not
# interested in testing this part of the request serialization for
# these tests so we're replacing the file like object with nothing. We
# can still verify that the params['payload'] is the expected file like
# object that has the correct contents but we won't test that it's
# serialized properly.
params['payload'] = None

def register_uri(self):
httpretty.register_uri(httpretty.PUT, re.compile('.*'), body='')

def test_simple(self):
cmdline = self.prefix
cmdline += ' --bucket mybucket'
cmdline += ' --tagging %s' % TAGSET
result = {'uri_params': {'Bucket': 'mybucket'},
'headers': {'Content-MD5': '5s++BGwLE2moBAK9duxpFw=='}}
self.assert_params_for_cmd(cmdline, result)


if __name__ == "__main__":
unittest.main()

0 comments on commit 1934e84

Please sign in to comment.