Skip to content

Conversation

@dhermes
Copy link
Contributor

@dhermes dhermes commented Feb 23, 2017

@lukesneeringer @tseaver any ideas on an easy "lint"-like check that will scream if people create a Mock() without a spec?

SIDEBAR: The error reporting unit tests are in a very bad state. This change opened my eyes to that fact, but I fear there is more hiding under the surface.

@dhermes dhermes added api: clouderrorreporting Issues related to the Error Reporting API. api: logging Issues related to the Cloud Logging API. api: vision Issues related to the Cloud Vision API. hygiene labels Feb 23, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 23, 2017
"""
channel = make_secure_channel(
client._connection.credentials,
client._credentials,

This comment was marked as spam.

@daspecster
Copy link
Contributor

Should mocks like mock.Mock(return_value=True) also pass in spec?

@dhermes
Copy link
Contributor Author

dhermes commented Feb 23, 2017

@daspecster All mocks should state their spec. Maybe we should even extend this to mock.patch?

@waprin
Copy link
Contributor

waprin commented Feb 27, 2017

Apologies if you don't think unit tests are up to snuff, thank you for improving.

I think a system test will inspire the most confidence in the functionality. When I first contributed the PR the API wasn't full fleshed out, but now that it is I can write one.

dhermes added 3 commits March 1, 2017 15:26
This actually required a much more comprehensive set of
unit test changes than expected.

Also incorporated a change from googleapis#3057 (which slipped through
due to overly broad mocks).
@dhermes dhermes force-pushed the make-mocks-less-broad branch from f4c9830 to c8e8a49 Compare March 1, 2017 23:26
@dhermes
Copy link
Contributor Author

dhermes commented Mar 1, 2017

Travis seems to be having issues, merging with CircleCI already green.

screenshot from 2017-03-01 15-56-04

@dhermes dhermes merged commit 17ac87f into googleapis:master Mar 1, 2017
@dhermes
Copy link
Contributor Author

dhermes commented Mar 1, 2017

Ahhh sorry I thought @daspecster had LGTM-ed! Eeek.

Worth reverting or someone just take a look ex-post-merge-o?

@dhermes dhermes deleted the make-mocks-less-broad branch March 1, 2017 23:57
@lukesneeringer
Copy link
Contributor

It's fine. :-)

richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Drop usage of overly broad mock.Mock() in tests.
parthea pushed a commit that referenced this pull request Oct 21, 2023
Drop usage of overly broad mock.Mock() in tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: clouderrorreporting Issues related to the Error Reporting API. api: logging Issues related to the Cloud Logging API. api: vision Issues related to the Cloud Vision API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants