Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2012 OpenStack, LLC |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 18 | from contextlib import closing |
| 19 | |
| 20 | from boto.s3.key import Key |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 21 | from nose.plugins.attrib import attr |
| 22 | import unittest2 as unittest |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 23 | |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 24 | from tempest import clients |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 25 | from tempest.common.utils.data_utils import rand_name |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 26 | from tempest.testboto import BotoTestCase |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 27 | from tempest.tests import boto |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 28 | |
| 29 | |
| 30 | @attr("S3") |
| 31 | class S3BucketsTest(BotoTestCase): |
| 32 | |
| 33 | @classmethod |
| 34 | def setUpClass(cls): |
| 35 | super(S3BucketsTest, cls).setUpClass() |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 36 | cls.os = clients.Manager() |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 37 | cls.client = cls.os.s3_client |
| 38 | cls.config = cls.os.config |
| 39 | |
| 40 | @unittest.skip("Skipped until the Bug #1076534 is resolved") |
| 41 | @attr(type='smoke') |
| 42 | def test_create_get_delete_object(self): |
Sean Dague | 64ef48d | 2013-01-03 17:54:36 -0500 | [diff] [blame] | 43 | # S3 Create, get and delete object |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 44 | bucket_name = rand_name("s3bucket-") |
| 45 | object_name = rand_name("s3object-") |
| 46 | content = 'x' * 42 |
| 47 | bucket = self.client.create_bucket(bucket_name) |
| 48 | self.addResourceCleanUp(self.destroy_bucket, |
| 49 | self.client.connection_data, |
| 50 | bucket_name) |
| 51 | |
| 52 | self.assertTrue(bucket.name == bucket_name) |
| 53 | with closing(Key(bucket)) as key: |
| 54 | key.key = object_name |
| 55 | key.set_contents_from_string(content) |
| 56 | readback = key.get_contents_as_string() |
| 57 | self.assertTrue(readback == content) |
| 58 | bucket.delete_key(key) |
| 59 | self.assertBotoError(self.s3_error_code.client.NoSuchKey, |
| 60 | key.get_contents_as_string) |