|
|
@@ -11,68 +11,68 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
|
|
|
super(CloudObjectStoreServiceTestCase, self).__init__(
|
|
|
methodName=methodName, provider=provider)
|
|
|
|
|
|
- def test_crud_container(self):
|
|
|
+ def test_crud_bucket(self):
|
|
|
"""
|
|
|
- Create a new container, check whether the expected values are set,
|
|
|
- and delete it
|
|
|
+ Create a new bucket, check whether the expected values are set,
|
|
|
+ and delete it.
|
|
|
"""
|
|
|
- name = "cbtestcreatecontainer-{0}".format(uuid.uuid4())
|
|
|
- test_container = self.provider.object_store.create(name)
|
|
|
- with helpers.cleanup_action(lambda: test_container.delete()):
|
|
|
+ name = "cbtestcreatebucket-{0}".format(uuid.uuid4())
|
|
|
+ test_bucket = self.provider.object_store.create(name)
|
|
|
+ with helpers.cleanup_action(lambda: test_bucket.delete()):
|
|
|
self.assertTrue(
|
|
|
- test_container.id in repr(test_container),
|
|
|
+ test_bucket.id in repr(test_bucket),
|
|
|
"repr(obj) should contain the object id so that the object"
|
|
|
" can be reconstructed, but does not. eval(repr(obj)) == obj")
|
|
|
|
|
|
- containers = self.provider.object_store.list()
|
|
|
+ buckets = self.provider.object_store.list()
|
|
|
|
|
|
- found_containers = [c for c in containers if c.name == name]
|
|
|
+ found_buckets = [c for c in buckets if c.name == name]
|
|
|
self.assertTrue(
|
|
|
- len(found_containers) == 1,
|
|
|
- "List containers does not return the expected container %s" %
|
|
|
+ len(found_buckets) == 1,
|
|
|
+ "List buckets does not return the expected bucket %s" %
|
|
|
name)
|
|
|
|
|
|
# check iteration
|
|
|
- found_containers = [c for c in self.provider.object_store
|
|
|
- if c.name == name]
|
|
|
+ found_buckets = [c for c in self.provider.object_store
|
|
|
+ if c.name == name]
|
|
|
self.assertTrue(
|
|
|
- len(found_containers) == 1,
|
|
|
- "Iter containers does not return the expected container %s" %
|
|
|
+ len(found_buckets) == 1,
|
|
|
+ "Iter buckets does not return the expected bucket %s" %
|
|
|
name)
|
|
|
|
|
|
- get_container = self.provider.object_store.get(
|
|
|
- test_container.id)
|
|
|
+ get_bucket = self.provider.object_store.get(
|
|
|
+ test_bucket.id)
|
|
|
self.assertTrue(
|
|
|
- found_containers[0] ==
|
|
|
- get_container == test_container,
|
|
|
+ found_buckets[0] ==
|
|
|
+ get_bucket == test_bucket,
|
|
|
"Objects returned by list: {0} and get: {1} are not as "
|
|
|
- " expected: {2}" .format(found_containers[0].id,
|
|
|
- get_container.id,
|
|
|
- test_container.name))
|
|
|
+ " expected: {2}" .format(found_buckets[0].id,
|
|
|
+ get_bucket.id,
|
|
|
+ test_bucket.name))
|
|
|
|
|
|
- containers = self.provider.object_store.list()
|
|
|
- found_containers = [c for c in containers if c.name == name]
|
|
|
+ buckets = self.provider.object_store.list()
|
|
|
+ found_buckets = [c for c in buckets if c.name == name]
|
|
|
self.assertTrue(
|
|
|
- len(found_containers) == 0,
|
|
|
- "Container %s should have been deleted but still exists." %
|
|
|
+ len(found_buckets) == 0,
|
|
|
+ "Bucket %s should have been deleted but still exists." %
|
|
|
name)
|
|
|
|
|
|
- def test_crud_container_objects(self):
|
|
|
+ def test_crud_bucket_objects(self):
|
|
|
"""
|
|
|
- Create a new container, upload some contents into the container, and
|
|
|
+ Create a new bucket, upload some contents into the bucket, and
|
|
|
check whether list properly detects the new content.
|
|
|
Delete everything afterwards.
|
|
|
"""
|
|
|
- name = "cbtestcontainerobjs-{0}".format(uuid.uuid4())
|
|
|
- test_container = self.provider.object_store.create(name)
|
|
|
+ name = "cbtestbucketobjs-{0}".format(uuid.uuid4())
|
|
|
+ test_bucket = self.provider.object_store.create(name)
|
|
|
|
|
|
- # ensure that the container is empty
|
|
|
- objects = test_container.list()
|
|
|
+ # ensure that the bucket is empty
|
|
|
+ objects = test_bucket.list()
|
|
|
self.assertEqual([], objects)
|
|
|
|
|
|
- with helpers.cleanup_action(lambda: test_container.delete()):
|
|
|
+ with helpers.cleanup_action(lambda: test_bucket.delete()):
|
|
|
obj_name = "hello_world.txt"
|
|
|
- obj = test_container.create_object(obj_name)
|
|
|
+ obj = test_bucket.create_object(obj_name)
|
|
|
|
|
|
self.assertTrue(
|
|
|
obj.id in repr(obj),
|
|
|
@@ -85,16 +85,16 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
|
|
|
# the content. Maybe the create_object method should accept
|
|
|
# the file content as a parameter.
|
|
|
obj.upload("dummy content")
|
|
|
- objs = test_container.list()
|
|
|
+ objs = test_bucket.list()
|
|
|
|
|
|
# check iteration
|
|
|
- iter_objs = list(test_container)
|
|
|
+ iter_objs = list(test_bucket)
|
|
|
self.assertListEqual(iter_objs, objs)
|
|
|
|
|
|
found_objs = [o for o in objs if o.name == obj_name]
|
|
|
self.assertTrue(
|
|
|
len(found_objs) == 1,
|
|
|
- "List container objects does not return the expected"
|
|
|
+ "List bucket objects does not return the expected"
|
|
|
" object %s" % obj_name)
|
|
|
|
|
|
self.assertTrue(
|
|
|
@@ -103,24 +103,24 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
|
|
|
" expected: {1}" .format(found_objs[0].id,
|
|
|
obj.id))
|
|
|
|
|
|
- objs = test_container.list()
|
|
|
+ objs = test_bucket.list()
|
|
|
found_objs = [o for o in objs if o.name == obj_name]
|
|
|
self.assertTrue(
|
|
|
len(found_objs) == 0,
|
|
|
"Object %s should have been deleted but still exists." %
|
|
|
obj_name)
|
|
|
|
|
|
- def test_upload_download_container_content(self):
|
|
|
+ def test_upload_download_bucket_content(self):
|
|
|
|
|
|
- name = "cbtestcontainerobjs-{0}".format(uuid.uuid4())
|
|
|
- test_container = self.provider.object_store.create(name)
|
|
|
+ name = "cbtestbucketobjs-{0}".format(uuid.uuid4())
|
|
|
+ test_bucket = self.provider.object_store.create(name)
|
|
|
|
|
|
- with helpers.cleanup_action(lambda: test_container.delete()):
|
|
|
+ with helpers.cleanup_action(lambda: test_bucket.delete()):
|
|
|
obj_name = "hello_upload_download.txt"
|
|
|
- obj = test_container.create_object(obj_name)
|
|
|
+ obj = test_bucket.create_object(obj_name)
|
|
|
|
|
|
with helpers.cleanup_action(lambda: obj.delete()):
|
|
|
- content = b"Hello World. Here's some content"
|
|
|
+ content = b"Hello World. Here's some content."
|
|
|
# TODO: Upload and download methods accept different parameter
|
|
|
# types. Need to make this consistent - possibly provider
|
|
|
# multiple methods like upload_from_file, from_stream etc.
|