def test_set_explicit_None_wo_connection_set(self): from gcloud.storage._testing import _monkey_defaults from gcloud.storage import _implicit_environ IMPLICIT_BUCKET_NAME = 'IMPLICIT' with self._monkeyEnviron(IMPLICIT_BUCKET_NAME): with _monkey_defaults(): self._callFUT(None) self.assertEqual(_implicit_environ.get_default_bucket(), None)
def test_set_explicit_None_wo_env_var_set(self): from gcloud.storage._testing import _monkey_defaults from gcloud.storage import _implicit_environ CONNECTION = object() with self._monkeyEnviron(None): with _monkey_defaults(connection=CONNECTION): self._callFUT(None) self.assertEqual(_implicit_environ.get_default_bucket(), None)
def test_no_env_var_set(self): from gcloud.storage._testing import _monkey_defaults from gcloud.storage import _implicit_environ with self._monkeyEnviron(None): with _monkey_defaults(): self._callFUT() self.assertEqual(_implicit_environ.get_default_bucket(), None)
def test_set_explicit_w_env_var_set(self): from gcloud.storage._testing import _monkey_defaults from gcloud.storage import _implicit_environ EXPLICIT_BUCKET = object() with self._monkeyEnviron(None): with _monkey_defaults(): self._callFUT(EXPLICIT_BUCKET) self.assertEqual(_implicit_environ.get_default_bucket(), EXPLICIT_BUCKET)
def __init__(self, name, bucket=None): if bucket is None: bucket = _implicit_environ.get_default_bucket() if bucket is None: raise ValueError('A Blob must have a bucket set.') super(Blob, self).__init__(name=name) self.bucket = bucket self._acl = ObjectACL(self)
def test_set_from_env_var(self): from gcloud.storage._testing import _monkey_defaults from gcloud.storage import _implicit_environ IMPLICIT_BUCKET_NAME = 'IMPLICIT' CONNECTION = object() with self._monkeyEnviron(IMPLICIT_BUCKET_NAME): with _monkey_defaults(connection=CONNECTION): self._callFUT() default_bucket = _implicit_environ.get_default_bucket() self.assertEqual(default_bucket.name, IMPLICIT_BUCKET_NAME)
def test_set_explicit_no_env_var_set(self): from gcloud.storage._testing import _monkey_defaults from gcloud.storage import _implicit_environ IMPLICIT_BUCKET_NAME = 'IMPLICIT' CONNECTION = object() EXPLICIT_BUCKET = object() with self._monkeyEnviron(IMPLICIT_BUCKET_NAME): with _monkey_defaults(connection=CONNECTION): self._callFUT(EXPLICIT_BUCKET) self.assertEqual(_implicit_environ.get_default_bucket(), EXPLICIT_BUCKET)
def test_set_from_env_var(self): from gcloud.storage._testing import _monkey_defaults from gcloud.storage import _implicit_environ IMPLICIT_BUCKET_NAME = 'IMPLICIT' CONNECTION = object() with self._monkeyEnviron(IMPLICIT_BUCKET_NAME): with _monkey_defaults(connection=CONNECTION): self._callFUT() default_bucket = _implicit_environ.get_default_bucket() self.assertEqual(default_bucket.name, IMPLICIT_BUCKET_NAME) self.assertEqual(default_bucket.connection, CONNECTION)
def __init__(self, name, bucket=None, chunk_size=None): if bucket is None: bucket = _implicit_environ.get_default_bucket() if bucket is None: raise ValueError('A Blob must have a bucket set.') super(Blob, self).__init__(name=name) self.chunk_size = chunk_size # Check that setter accepts value. self.bucket = bucket self._acl = ObjectACL(self)
def _callFUT(self): from gcloud.storage._implicit_environ import get_default_bucket return get_default_bucket()