-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
""" | ||
|
||
def __init__(self, connection=None, dataset_id=None, implicit=False): | ||
self.implicit = implicit |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
I don't grasp the "main delta" bit: are you saying that was stuff you used to find places relying on implicit values, but didn't check it in after fixing them? |
This PR is really just about using The diff above is a hack I used to sniff out tests that relied on implicit behavior. It makes it so that anytime if self.implicit:
raise self.FooError So if the container being tested was implicit, the test would fail. (I made a custom error, so it didn't get caught by any |
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():
1f990e0
to
5e281dd
Compare
LGTM. (I think some of this commit gets backed out in #667 anyway). |
Adding datastore _DEFAULTS stubs in all tests that use it.
* feat: added baseline model version used to generate the summary feat: added the platform of the virtual agent response messages PiperOrigin-RevId: 555788605 Source-Link: googleapis/googleapis@90a551c Source-Link: googleapis/googleapis-gen@30620b4 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzA2MjBiNGYzNDcxMzg2MDA4M2ZmZjAzNjk4MjkwMGIxMDA0Y2JmNSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
NOTE: Has #664 as diffbase
Introduces
implicit
for_DefaultsContainer
.Verified all test cases that would accidentally rely on _DEFAULTS implicit
behavior by using a custom
_DefaultsContainer
that raises when theinstance is implicit.
Main delta for the custom properties: