Skip to content

Commit

Permalink
feat: Multi db test parametrization (#717)
Browse files Browse the repository at this point in the history
* feat: Multi db test parametrization

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.

* Fix unit test import

* Fix unit test import

* fix: change non-default database name

* fix: added client test without any database set

---------

Co-authored-by: Vishwaraj Anand <vishwaraj.anand00@gmail.com>
Co-authored-by: kolea2 <45548808+kolea2@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
4 people committed Jul 18, 2023
1 parent 1706ef4 commit 91fc8bb
Show file tree
Hide file tree
Showing 14 changed files with 655 additions and 368 deletions.
3 changes: 1 addition & 2 deletions google/cloud/firestore_v1/async_client.py
Expand Up @@ -29,7 +29,6 @@

from google.cloud.firestore_v1.base_client import (
BaseClient,
DEFAULT_DATABASE,
_CLIENT_INFO,
_parse_batch_get, # type: ignore
_path_helper,
Expand Down Expand Up @@ -88,7 +87,7 @@ def __init__(
self,
project=None,
credentials=None,
database=DEFAULT_DATABASE,
database=None,
client_info=_CLIENT_INFO,
client_options=None,
) -> None:
Expand Down
3 changes: 2 additions & 1 deletion google/cloud/firestore_v1/base_client.py
Expand Up @@ -117,10 +117,11 @@ def __init__(
self,
project=None,
credentials=None,
database=DEFAULT_DATABASE,
database=None,
client_info=_CLIENT_INFO,
client_options=None,
) -> None:
database = database or DEFAULT_DATABASE
# NOTE: This API has no use for the _http argument, but sending it
# will have no impact since the _http() @property only lazily
# creates a working HTTP object.
Expand Down
3 changes: 1 addition & 2 deletions google/cloud/firestore_v1/client.py
Expand Up @@ -29,7 +29,6 @@

from google.cloud.firestore_v1.base_client import (
BaseClient,
DEFAULT_DATABASE,
_CLIENT_INFO,
_parse_batch_get,
_path_helper,
Expand Down Expand Up @@ -86,7 +85,7 @@ def __init__(
self,
project=None,
credentials=None,
database=DEFAULT_DATABASE,
database=None,
client_info=_CLIENT_INFO,
client_options=None,
) -> None:
Expand Down
1 change: 1 addition & 0 deletions tests/system/test__helpers.py
Expand Up @@ -12,3 +12,4 @@
UNIQUE_RESOURCE_ID = unique_resource_id("-")
EMULATOR_CREDS = EmulatorCreds()
FIRESTORE_EMULATOR = os.environ.get(_FIRESTORE_EMULATOR_HOST) is not None
FIRESTORE_OTHER_DB = os.environ.get("SYSTEM_TESTS_DATABASE", "system-tests-named-db")

0 comments on commit 91fc8bb

Please sign in to comment.