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

feat: add Prefixer class to generate and parse resource names #39

Merged
merged 5 commits into from
Jul 7, 2021

Conversation

tswast
Copy link
Contributor

@tswast tswast commented Jul 2, 2021

This Prefixer class is intended to be created once per test file and/or test suite (such as in a conftest.py file). It can be used to generate standard resource names, which can easily identify which test suite created them. Also, since they contain the UTC date/time that the resource was created to facilitate cleanup fixtures.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #10 🦕

@tswast tswast requested a review from a team as a code owner July 2, 2021 21:48
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 2, 2021
test_utils/prefixer.py Outdated Show resolved Hide resolved
test_utils/prefixer.py Outdated Show resolved Hide resolved
Co-authored-by: Tres Seaver <[email protected]>
@google-cla
Copy link

google-cla bot commented Jul 7, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jul 7, 2021
Co-authored-by: Tres Seaver <[email protected]>
@google-cla
Copy link

google-cla bot commented Jul 7, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@tswast tswast added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jul 7, 2021
@tswast tswast requested a review from tseaver July 7, 2021 14:14
@google-cla
Copy link

google-cla bot commented Jul 7, 2021

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jul 7, 2021
@tswast tswast added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jul 7, 2021
@tseaver tseaver merged commit 865480b into master Jul 7, 2021
@tseaver tseaver deleted the issue10-resource-prefixes branch July 7, 2021 17:46
Comment on lines +24 to +26
"""Fake datetime class since pytest can't monkeypatch attributes of
built-in/extension type.
"""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would using freezegun represent a viable alternative?

True, it would be a new dependency, but it's widely used and maintained, and supports a wide range of features.

(the downside is that the more recent versions require Python 3.5+, but it could still be an option when Python 2.7 support is finally dropped in all libraries)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, freezegun would have been the more robust choice. Indeed, I didn't want to introduce a new dependency just for this.

gcf-merge-on-green bot pushed a commit to googleapis/python-bigquery that referenced this pull request Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

methods to create and parse standard resource prefixes with repo_name, directory_path as parameters
3 participants