Skip to content

Commit b59f825

Browse files
HomelessDinosaurjyecusch
authored andcommitted
docs: Add collection subcollection examples and tests
1 parent 703cc62 commit b59f825

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# # [START import]
2-
# from nitric.api import Documents
3-
# # [END import]
4-
# async def documents_sub_col_query():
5-
# # [START snippet]
6-
# docs = Documents()
1+
# [START import]
2+
from nitric.api import Documents
3+
# [END import]
4+
async def documents_sub_col_query():
5+
# [START snippet]
6+
docs = Documents()
77

8-
# query = (docs.collection("Customers")
9-
# .collection("Orders")
10-
# .query())
8+
query = (docs.collection("Customers")
9+
.collection("Orders")
10+
.query())
1111

12-
# results = await query.fetch()
13-
# # [END snippet]
12+
results = await query.fetch()
13+
# [END snippet]

tests/examples/test_documents_example.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from examples.documents.sub_col_query import documents_sub_col_query
12
from nitric.proto.nitric.document.v1 import Collection, DocumentGetResponse, DocumentQueryStreamResponse, Document, Key
23
from examples.documents.set import documents_set
34
from examples.documents.get import documents_get
@@ -96,6 +97,14 @@ async def test_sub_doc_query_document(self):
9697

9798
mock_query.assert_called_once()
9899

100+
async def test_sub_col_query_document(self):
101+
mock_query = AsyncMock()
102+
103+
with patch("nitric.proto.nitric.document.v1.DocumentServiceStub.query", mock_query):
104+
await documents_sub_col_query()
105+
106+
mock_query.assert_called_once()
107+
99108
async def test_streamed_document(self):
100109
stream_calls = 0
101110
call_args = {}

0 commit comments

Comments
 (0)