Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding datastore _DEFAULTS stubs in all tests that use it. #665

Merged
merged 1 commit into from
Feb 19, 2015

Commits on Feb 19, 2015

  1. Adding _DEFAULTS stubs in all tests that use it.

    Introduces
    - concept of `implicit` for `_DefaultsContainer`.
    - testing module for datastore for patching
    
    Verified all test cases that would accidentally rely on _DEFAULTS implicit
    behavior by using a custom `_DefaultsContainer` that raises when the
    instance is implicit.
    
    Main delta for the custom properties:
    
    diff --git a/gcloud/datastore/_implicit_environ.py b/gcloud/datastore/_implicit_environ.py
    index 3afc954..1d38562 100644
    --- a/gcloud/datastore/_implicit_environ.py
    +++ b/gcloud/datastore/_implicit_environ.py
    @@ -38,9 +38,37 @@ class _DefaultsContainer(object):
         :param dataset_id: Persistent implied dataset ID from environment.
         """
    
    -    def __init__(self, connection=None, dataset_id=None):
    -        self.connection = connection
    -        self.dataset_id = dataset_id
    +    class FooError(Exception):
    +        pass
    +
    +    @Property
    +    def dataset_id(self):
    +        if self.implicit:
    +            raise self.FooError
    +        return self._dataset_id
    +
    +    @dataset_id.setter
    +    def dataset_id(self, value):
    +        if self.implicit:
    +            raise self.FooError
    +        self._dataset_id = value
    +
    +    @Property
    +    def connection(self):
    +        if self.implicit:
    +            raise self.FooError
    +        return self._connection
    +
    +    @connection.setter
    +    def connection(self, value):
    +        if self.implicit:
    +            raise self.FooError
    +        self._connection = value
    +
    +    def __init__(self, connection=None, dataset_id=None, implicit=False):
    +        self.implicit = implicit
    +        self._connection = connection
    +        self._dataset_id = dataset_id
    
     def app_engine_id():
    dhermes committed Feb 19, 2015
    Configuration menu
    Copy the full SHA
    5e281dd View commit details
    Browse the repository at this point in the history