Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
    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)
Esempio n. 5
0
 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)
Esempio n. 6
0
    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)
Esempio n. 7
0
    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)
Esempio n. 8
0
    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)
Esempio n. 9
0
    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)
Esempio n. 10
0
    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)
Esempio n. 11
0
    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)
Esempio n. 12
0
    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)
Esempio n. 13
0
    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)
Esempio n. 14
0
    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()
 def _callFUT(self):
     from gcloud.storage._implicit_environ import get_default_bucket
     return get_default_bucket()