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: Multi db test parametrization #717

Merged
merged 14 commits into from Jul 18, 2023
Merged

Conversation

Mariatta
Copy link
Contributor

The changes are:

  • adding test parametrization wherever the client is used. It will run the test against the default db, and a named db named db can only be passed to the Client, and the underlying queries and aggregation queries will retrieve the database id from the Client.

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 #<issue_number_goes_here> 🦕

The changes are:

- adding test parametrization wherever the client is used. It will run the test against the default db, and a named db
named db can only be passed to the Client, and the underlying queries and aggregation queries will retrieve the database id from the Client.
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: firestore Issues related to the googleapis/python-firestore API. labels May 11, 2023
Copy link
Contributor

@kolea2 kolea2 left a comment

Choose a reason for hiding this comment

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

I dont think the ITs were run since this is a draft PR - can we convert to ready for review?

tests/system/test__helpers.py Outdated Show resolved Hide resolved
@parthea parthea added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Jul 5, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 5, 2023
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jul 5, 2023
@vishwarajanand vishwarajanand marked this pull request as ready for review July 10, 2023 18:07
@vishwarajanand vishwarajanand requested review from a team as code owners July 10, 2023 18:07
@@ -36,26 +37,42 @@ def _make_credentials():

def _make_default_client(*args, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be great to add one additional test without parameterization testing client initialization with:

  1. not setting the database
  2. setting the database
  3. setting the database to None

and asserting the database is set correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kolea2 there are 2 approaches to tackle this:

  1. (current - neater approach but tests only client initialization) Adds test_client_constructor_without_db where DB isn't set and the database is asserted to equal DEFAULT_DATABASE

  2. (Code become less readable, but tests are more exhaustive) we can add a check in _make_default_client to not use database param when it's an empty string during the client initialization.

I choose the first approach for readability, but I have no qualms with the second one too. Leaving this comment open for now for Python reviewers.

Copy link
Contributor

@kolea2 kolea2 left a comment

Choose a reason for hiding this comment

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

lgtm, will defer to @googleapis/yoshi-python for the remaining review!

@kolea2 kolea2 merged commit 91fc8bb into main Jul 18, 2023
16 checks passed
@kolea2 kolea2 deleted the feat-multidb-test-parametrization branch July 18, 2023 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants