Exemplo n.º 1
0
 def test_create_bucket(self):
     new_bucket_name = 'a-new-bucket'
     self.assertRaises(exceptions.NotFound,
                       storage.get_bucket, new_bucket_name)
     created = storage.create_bucket(new_bucket_name)
     self.case_buckets_to_delete.append(new_bucket_name)
     self.assertEqual(created.name, new_bucket_name)
Exemplo n.º 2
0
 def test_create_bucket(self):
     new_bucket_name = 'a-new-bucket'
     self.assertRaises(exceptions.NotFound,
                       storage.get_bucket, new_bucket_name)
     created = storage.create_bucket(new_bucket_name)
     self.case_buckets_to_delete.append(new_bucket_name)
     self.assertEqual(created.name, new_bucket_name)
Exemplo n.º 3
0
def setUpModule():
    if 'test_bucket' not in SHARED_BUCKETS:
        # %d rounds milliseconds to nearest integer.
        bucket_name = 'new%d' % (1000 * time.time(),)
        # In the **very** rare case the bucket name is reserved, this
        # fails with a ConnectionError.
        SHARED_BUCKETS['test_bucket'] = storage.create_bucket(bucket_name)
Exemplo n.º 4
0
def setUpModule():
    if 'test_bucket' not in SHARED_BUCKETS:
        # %d rounds milliseconds to nearest integer.
        bucket_name = 'new%d' % (1000 * time.time(),)
        # In the **very** rare case the bucket name is reserved, this
        # fails with a ConnectionError.
        SHARED_BUCKETS['test_bucket'] = storage.create_bucket(bucket_name)
Exemplo n.º 5
0
    def test_get_buckets(self):
        buckets_to_create = [
            'new%d' % (1000 * time.time(),),
            'newer%d' % (1000 * time.time(),),
            'newest%d' % (1000 * time.time(),),
        ]
        created_buckets = []
        for bucket_name in buckets_to_create:
            bucket = storage.create_bucket(bucket_name)
            self.case_buckets_to_delete.append(bucket_name)

        # Retrieve the buckets.
        all_buckets = storage.get_all_buckets()
        created_buckets = [bucket for bucket in all_buckets
                           if bucket.name in buckets_to_create]
        self.assertEqual(len(created_buckets), len(buckets_to_create))
Exemplo n.º 6
0
    def test_get_buckets(self):
        buckets_to_create = [
            'new%d' % (1000 * time.time(),),
            'newer%d' % (1000 * time.time(),),
            'newest%d' % (1000 * time.time(),),
        ]
        created_buckets = []
        for bucket_name in buckets_to_create:
            bucket = storage.create_bucket(bucket_name)
            self.case_buckets_to_delete.append(bucket_name)

        # Retrieve the buckets.
        all_buckets = storage.list_buckets()
        created_buckets = [bucket for bucket in all_buckets
                           if bucket.name in buckets_to_create]
        self.assertEqual(len(created_buckets), len(buckets_to_create))
Exemplo n.º 7
0
def create_bucket(bucket_name, connection):
    return storage.create_bucket(bucket_name,
                                 PROJECT_ID,
                                 connection=connection)
Exemplo n.º 8
0
def _get_bucket():
    try:
        return storage.get_bucket(BUCKET_NAME)
    except NotFound:
        return storage.create_bucket(BUCKET_NAME)
Exemplo n.º 9
0
def create_bucket(bucket_name, connection):
    return storage.create_bucket(bucket_name, PROJECT_ID,
                                 connection=connection)