Index: tests/s3/test_gsconnection.py |
diff --git a/boto/tests/test_gsconnection.py b/tests/s3/test_gsconnection.py |
similarity index 79% |
rename from boto/tests/test_gsconnection.py |
rename to tests/s3/test_gsconnection.py |
index 5c324fa166840ce4eca0ed5b43279ad0ebf08bbc..e38f442165eee500053db1ec1bf3233b1e374bd4 100644 |
--- a/boto/tests/test_gsconnection.py |
+++ b/tests/s3/test_gsconnection.py |
@@ -1,7 +1,7 @@ |
-#!/usr/bin/env python |
# -*- coding: utf-8 -*- |
-# Copyright (c) 2006-2010 Mitch Garnaat http://garnaat.org/ |
+# Copyright (c) 2006-2011 Mitch Garnaat http://garnaat.org/ |
# Copyright (c) 2010, Eucalyptus Systems, Inc. |
+# Copyright (c) 2011, Nexenta Systems, Inc. |
# All rights reserved. |
# |
# Permission is hereby granted, free of charge, to any person obtaining a |
@@ -18,7 +18,7 @@ |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
# IN THE SOFTWARE. |
@@ -76,6 +76,20 @@ class GSConnectionTest (unittest.TestCase): |
md5 = k.md5 |
k.set_contents_from_string(s2) |
assert k.md5 != md5 |
+ # Test for stream API |
+ fp2 = open('foobar', 'rb') |
+ k.md5 = None |
+ k.base64md5 = None |
+ k.set_contents_from_stream(fp2, headers=headers) |
+ fp = open('foobar1', 'wb') |
+ k.get_contents_to_file(fp) |
+ fp.close() |
+ fp2.seek(0,0) |
+ fp = open('foobar1', 'rb') |
+ assert (fp2.read() == fp.read()), 'Chunked Transfer corrupted the Data' |
+ fp.close() |
+ fp2.close() |
+ os.unlink('foobar1') |
os.unlink('foobar') |
all = bucket.get_all_keys() |
assert len(all) == 6 |
@@ -101,12 +115,12 @@ class GSConnectionTest (unittest.TestCase): |
mdval2 = 'This is the second metadata value' |
k.set_metadata(mdkey2, mdval2) |
# try a unicode metadata value |
- |
+ |
mdval3 = u'föö' |
mdkey3 = 'meta3' |
k.set_metadata(mdkey3, mdval3) |
k.set_contents_from_string(s1) |
- |
+ |
k = bucket.lookup('has_metadata') |
assert k.get_metadata(mdkey1) == mdval1 |
assert k.get_metadata(mdkey2) == mdval2 |
@@ -140,6 +154,22 @@ class GSConnectionTest (unittest.TestCase): |
k.set_acl('private') |
acl = k.get_acl() |
assert len(acl.entries.entry_list) == 1 |
+ # try set/get raw logging subresource |
+ empty_logging_str="<?xml version='1.0' encoding='UTF-8'?><Logging/>" |
+ logging_str = ( |
+ "<?xml version='1.0' encoding='UTF-8'?><Logging>" |
+ "<LogBucket>log-bucket</LogBucket>" + |
+ "<LogObjectPrefix>example</LogObjectPrefix>" + |
+ "<PredefinedAcl>bucket-owner-full-control</PredefinedAcl>" + |
+ "</Logging>") |
+ bucket.set_subresource('logging', logging_str); |
+ assert bucket.get_subresource('logging') == logging_str; |
+ # try disable/enable logging |
+ bucket.disable_logging() |
+ assert bucket.get_subresource('logging') == empty_logging_str |
+ bucket.enable_logging('log-bucket', 'example', |
+ canned_acl='bucket-owner-full-control') |
+ assert bucket.get_subresource('logging') == logging_str; |
# now delete all keys in bucket |
for k in bucket: |
bucket.delete_key(k) |