-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Adding datastore _DEFAULTS stubs in all tests that use it. #665
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
Conversation
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.FooErrorSo 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>
* chore(deps): update all dependencies * 🦉 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> Co-authored-by: Anthonios Partheniou <[email protected]>
* chore(python): exclude setup.py in renovate config Source-Link: googleapis/synthtool@56da63e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:993a058718e84a82fda04c3177e58f0a43281a996c7c395e0a56ccc4d6d210d7 * increase timeouts Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
This reverts commit d96eb5cdd8120bfec97d62b09512c6fecc325be8.
NOTE: Has #664 as diffbase
Introduces
implicitfor_DefaultsContainer.Verified all test cases that would accidentally rely on _DEFAULTS implicit
behavior by using a custom
_DefaultsContainerthat raises when theinstance is implicit.
Main delta for the custom properties: