forked from aws/aws-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-md5-handler' of git://github.com/garnaat/aws-cli in…
…to garnaat-fix-md5-handler
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |