From 99a9fd933c0c72d64735112a36e62753cf6e2d3a Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 19 Jul 2019 15:41:39 -0400 Subject: [PATCH 1/2] Fix V1 'Client.collections' method. Add undocumented-but-required '/documents' to the database path. Closes #8717. --- firestore/google/cloud/firestore_v1/client.py | 2 +- firestore/tests/system.py | 4 ++++ firestore/tests/unit/v1/test_client.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/firestore/google/cloud/firestore_v1/client.py b/firestore/google/cloud/firestore_v1/client.py index 56356d97911b..54e2585bed3a 100644 --- a/firestore/google/cloud/firestore_v1/client.py +++ b/firestore/google/cloud/firestore_v1/client.py @@ -421,7 +421,7 @@ def collections(self): iterator of subcollections of the current document. """ iterator = self._firestore_api.list_collection_ids( - self._database_string, metadata=self._rpc_metadata + "{}/documents".format(self._database_string), metadata=self._rpc_metadata ) iterator.client = self iterator.item_to_value = _item_to_collection_ref diff --git a/firestore/tests/system.py b/firestore/tests/system.py index 4d9de9be43be..13f15b107670 100644 --- a/firestore/tests/system.py +++ b/firestore/tests/system.py @@ -57,6 +57,10 @@ def cleanup(): operation() +def test_collections(client): + collections = list(client.collections()) + assert isinstance(collections, list) + def test_create_document(client, cleanup): now = datetime.datetime.utcnow().replace(tzinfo=UTC) collection_id = "doc-create" + unique_resource_id("-") diff --git a/firestore/tests/unit/v1/test_client.py b/firestore/tests/unit/v1/test_client.py index 737d2313656a..be054d8ce775 100644 --- a/firestore/tests/unit/v1/test_client.py +++ b/firestore/tests/unit/v1/test_client.py @@ -292,8 +292,9 @@ def _next_page(self): self.assertEqual(collection.parent, None) self.assertEqual(collection.id, collection_id) + base_path = client._database_string + "/documents" firestore_api.list_collection_ids.assert_called_once_with( - client._database_string, metadata=client._rpc_metadata + base_path, metadata=client._rpc_metadata ) def _get_all_helper(self, client, references, document_pbs, **kwargs): From 2cf03ac2f43dd43ecaed81251166076ba9d90b37 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 19 Jul 2019 16:10:53 -0400 Subject: [PATCH 2/2] Blacken. --- firestore/tests/system.py | 1 + 1 file changed, 1 insertion(+) diff --git a/firestore/tests/system.py b/firestore/tests/system.py index 13f15b107670..01e89844291c 100644 --- a/firestore/tests/system.py +++ b/firestore/tests/system.py @@ -61,6 +61,7 @@ def test_collections(client): collections = list(client.collections()) assert isinstance(collections, list) + def test_create_document(client, cleanup): now = datetime.datetime.utcnow().replace(tzinfo=UTC) collection_id = "doc-create" + unique_resource_id("-")