Skip to content

Commit ab8e59d

Browse files
test: update conf tests (#291)
* test: update conf tests * test: use relative directories, not hardcoded, in conf test makefile * test: add format at end of generation * test: remove unused var * Updated Makefile to make less assumptions about project structure Co-authored-by: Craig Labenz <craig.labenz@gmail.com>
1 parent ca31b9b commit ab8e59d

File tree

6 files changed

+133
-56
lines changed

6 files changed

+133
-56
lines changed

packages/google-cloud-firestore/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ system_tests/local_test_setup
6060
# Make sure a generated file isn't accidentally committed.
6161
pylintrc
6262
pylintrc.test
63+
.make/**

packages/google-cloud-firestore/CONTRIBUTING.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,21 @@ Running System Tests
146146
`docs <https://cloud.google.com/storage/docs/authentication#generating-a-private-key>`__
147147
for more details.
148148

149-
- Once you have downloaded your json keys, set the environment variable
149+
- Once you have downloaded your json keys, set the environment variable
150150
``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file::
151151

152152
$ export GOOGLE_APPLICATION_CREDENTIALS="/Users/<your_username>/path/to/app_credentials.json"
153153

154+
**************************
155+
Updating Conformance Tests
156+
**************************
157+
158+
The firestore client libraries use a shared set of conformance tests, the source of which can be found at https://github.com/googleapis/conformance-tests.
159+
160+
To update the copy of these conformance tests used by this repository, run the provided Makefile:
161+
162+
$ make -f Makefile_v1
163+
154164

155165
*************
156166
Test Coverage

packages/google-cloud-firestore/Makefile_v1

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,32 @@
55
PROTOC = protoc
66

77
# Dependent repos.
8-
REPO_DIR=$(HOME)/git-repos
9-
PROTOBUF_REPO = $(REPO_DIR)/protobuf
10-
GOOGLEAPIS_REPO = $(REPO_DIR)/googleapis
11-
TESTS_REPO = $(REPO_DIR)/conformance-tests
8+
REPO_DIR = $(shell pwd)
9+
BUILD_DIR = $(shell pwd)/.make
10+
# This requires a few other repositories, assumed to be in the same root
11+
# of this repository.
12+
# => git clone git@github.com:protocolbuffers/protobuf
13+
PROTOBUF_REPO = $(BUILD_DIR)/protobuf
14+
# => git clone git@github.com:googleapis/googleapis.git
15+
GOOGLEAPIS_REPO = $(BUILD_DIR)/googleapis
16+
# => git clone git@github.com:googleapis/conformance-tests.git
17+
TESTS_REPO = $(BUILD_DIR)/conformance-tests
18+
1219
TEST_PROTO_DIR = $(TESTS_REPO)/firestore/v1
1320
TEST_PROTO_SRC = $(TEST_PROTO_DIR)/proto/google/cloud/conformance/firestore/v1/tests.proto
14-
TESTDATA_DIR = `pwd`/tests/unit/v1/testdata/
21+
TESTDATA_DIR = $(REPO_DIR)/tests/unit/v1/testdata/
1522

16-
TMPDIR = /tmp/python-fs-proto
23+
TMPDIR = $(BUILD_DIR)/python-fs-proto
1724
TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1/types
1825
TEST_PROTO_COPY = $(TMPDIR_FS)/tests.proto
1926
TEST_GEN_OUT = tests/unit/v1/conformance_tests.py
20-
OUTDIR = /tmp/python-fs-gen
27+
OUTDIR = $(BUILD_DIR)/python-fs-gen
28+
29+
.PHONY: sync gen-protos docker-pull all format clean
2130

22-
.PHONY: sync-protos gen-protos docker-pull
31+
all: gen-protos copy-testdata clean
2332

24-
gen-protos: sync-protos tweak-protos docker-pull gen-protos-raw
33+
gen-protos: sync tweak-protos docker-pull gen-protos-raw format
2534

2635
gen-protos-raw:
2736
mkdir -p $(OUTDIR)
@@ -48,14 +57,23 @@ tweak-protos:
4857
sed -i -e 's@google\.firestore\.v1@google.cloud.firestore_v1@' $(TEST_PROTO_COPY)
4958
sed -i -e 's@Cursor@Cursor_@' $(TEST_PROTO_COPY)
5059

51-
sync-protos:
52-
cd $(PROTOBUF_REPO); git pull
53-
cd $(GOOGLEAPIS_REPO); git pull
54-
cd $(TESTS_REPO); git pull
60+
sync: clean
61+
mkdir -p $(PROTOBUF_REPO)
62+
git clone --depth 1 git@github.com:protocolbuffers/protobuf $(PROTOBUF_REPO)
63+
mkdir -p $(GOOGLEAPIS_REPO)
64+
git clone --depth 1 git@github.com:googleapis/googleapis.git $(GOOGLEAPIS_REPO)
65+
mkdir -p $(TESTS_REPO)
66+
git clone --depth 1 git@github.com:googleapis/conformance-tests.git $(TESTS_REPO)
5567

5668
docker-pull:
5769
docker pull gcr.io/gapic-images/gapic-generator-python:latest
5870

5971
copy-testdata:
6072
rm $(TESTDATA_DIR)/*.json
6173
cp $(TEST_PROTO_DIR)/*.json $(TESTDATA_DIR)/
74+
75+
format:
76+
nox -s blacken
77+
78+
clean:
79+
rm -rf $(BUILD_DIR)

packages/google-cloud-firestore/tests/unit/v1/conformance_tests.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class TestFile(proto.Message):
5656
r"""A collection of tests.
5757
5858
Attributes:
59-
tests (Sequence[~.gcf_tests.Test]):
59+
tests (Sequence[google.cloud.firestore_v1.types.Test]):
6060
6161
"""
6262

@@ -73,21 +73,21 @@ class Test(proto.Message):
7373
comment (str):
7474
a comment describing the behavior being
7575
tested
76-
get (~.gcf_tests.GetTest):
76+
get (google.cloud.firestore_v1.types.GetTest):
7777
78-
create (~.gcf_tests.CreateTest):
78+
create (google.cloud.firestore_v1.types.CreateTest):
7979
80-
set_ (~.gcf_tests.SetTest):
80+
set_ (google.cloud.firestore_v1.types.SetTest):
8181
82-
update (~.gcf_tests.UpdateTest):
82+
update (google.cloud.firestore_v1.types.UpdateTest):
8383
84-
update_paths (~.gcf_tests.UpdatePathsTest):
84+
update_paths (google.cloud.firestore_v1.types.UpdatePathsTest):
8585
86-
delete (~.gcf_tests.DeleteTest):
86+
delete (google.cloud.firestore_v1.types.DeleteTest):
8787
88-
query (~.gcf_tests.QueryTest):
88+
query (google.cloud.firestore_v1.types.QueryTest):
8989
90-
listen (~.gcf_tests.ListenTest):
90+
listen (google.cloud.firestore_v1.types.ListenTest):
9191
9292
"""
9393

@@ -121,7 +121,7 @@ class GetTest(proto.Message):
121121
doc_ref_path (str):
122122
The path of the doc, e.g.
123123
"projects/projectID/databases/(default)/documents/C/d".
124-
request (~.firestore.GetDocumentRequest):
124+
request (google.cloud.firestore_v1.types.GetDocumentRequest):
125125
The request that the call should send to the
126126
Firestore service.
127127
"""
@@ -146,7 +146,7 @@ class CreateTest(proto.Message):
146146
the two special sentinel values. Values that
147147
could be interpreted as integers (i.e. digit
148148
strings) should be treated as integers.
149-
request (~.firestore.CommitRequest):
149+
request (google.cloud.firestore_v1.types.CommitRequest):
150150
The request that the call should generate.
151151
is_error (bool):
152152
If true, the call should result in an error
@@ -169,11 +169,11 @@ class SetTest(proto.Message):
169169
Attributes:
170170
doc_ref_path (str):
171171
path of doc
172-
option (~.gcf_tests.SetOption):
172+
option (google.cloud.firestore_v1.types.SetOption):
173173
option to the Set call, if any
174174
json_data (str):
175175
data (see CreateTest.json_data)
176-
request (~.firestore.CommitRequest):
176+
request (google.cloud.firestore_v1.types.CommitRequest):
177177
expected request
178178
is_error (bool):
179179
call signals an error
@@ -197,11 +197,11 @@ class UpdateTest(proto.Message):
197197
Attributes:
198198
doc_ref_path (str):
199199
path of doc
200-
precondition (~.common.Precondition):
200+
precondition (google.cloud.firestore_v1.types.Precondition):
201201
precondition in call, if any
202202
json_data (str):
203203
data (see CreateTest.json_data)
204-
request (~.firestore.CommitRequest):
204+
request (google.cloud.firestore_v1.types.CommitRequest):
205205
expected request
206206
is_error (bool):
207207
call signals an error
@@ -225,14 +225,14 @@ class UpdatePathsTest(proto.Message):
225225
Attributes:
226226
doc_ref_path (str):
227227
path of doc
228-
precondition (~.common.Precondition):
228+
precondition (google.cloud.firestore_v1.types.Precondition):
229229
precondition in call, if any
230-
field_paths (Sequence[~.gcf_tests.FieldPath]):
230+
field_paths (Sequence[google.cloud.firestore_v1.types.FieldPath]):
231231
parallel sequences: field_paths[i] corresponds to
232232
json_values[i]
233233
json_values (Sequence[str]):
234234
the argument values, as JSON
235-
request (~.firestore.CommitRequest):
235+
request (google.cloud.firestore_v1.types.CommitRequest):
236236
expected rquest
237237
is_error (bool):
238238
call signals an error
@@ -257,9 +257,9 @@ class DeleteTest(proto.Message):
257257
Attributes:
258258
doc_ref_path (str):
259259
path of doc
260-
precondition (~.common.Precondition):
260+
precondition (google.cloud.firestore_v1.types.Precondition):
261261
262-
request (~.firestore.CommitRequest):
262+
request (google.cloud.firestore_v1.types.CommitRequest):
263263
expected rquest
264264
is_error (bool):
265265
call signals an error
@@ -281,7 +281,7 @@ class SetOption(proto.Message):
281281
all_ (bool):
282282
if true, merge all fields ("fields" is
283283
ignored).
284-
fields (Sequence[~.gcf_tests.FieldPath]):
284+
fields (Sequence[google.cloud.firestore_v1.types.FieldPath]):
285285
field paths for a Merge option
286286
"""
287287

@@ -297,9 +297,9 @@ class QueryTest(proto.Message):
297297
coll_path (str):
298298
path of collection, e.g.
299299
"projects/projectID/databases/(default)/documents/C".
300-
clauses (Sequence[~.gcf_tests.Clause]):
300+
clauses (Sequence[google.cloud.firestore_v1.types.Clause]):
301301
302-
query (~.gcf_query.StructuredQuery):
302+
query (google.cloud.firestore_v1.types.StructuredQuery):
303303
304304
is_error (bool):
305305
@@ -318,23 +318,23 @@ class Clause(proto.Message):
318318
r"""
319319
320320
Attributes:
321-
select (~.gcf_tests.Select):
321+
select (google.cloud.firestore_v1.types.Select):
322322
323-
where (~.gcf_tests.Where):
323+
where (google.cloud.firestore_v1.types.Where):
324324
325-
order_by (~.gcf_tests.OrderBy):
325+
order_by (google.cloud.firestore_v1.types.OrderBy):
326326
327327
offset (int):
328328
329329
limit (int):
330330
331-
start_at (~.gcf_tests.Cursor_):
331+
start_at (google.cloud.firestore_v1.types.Cursor_):
332332
333-
start_after (~.gcf_tests.Cursor_):
333+
start_after (google.cloud.firestore_v1.types.Cursor_):
334334
335-
end_at (~.gcf_tests.Cursor_):
335+
end_at (google.cloud.firestore_v1.types.Cursor_):
336336
337-
end_before (~.gcf_tests.Cursor_):
337+
end_before (google.cloud.firestore_v1.types.Cursor_):
338338
339339
"""
340340

@@ -365,7 +365,7 @@ class Select(proto.Message):
365365
r"""
366366
367367
Attributes:
368-
fields (Sequence[~.gcf_tests.FieldPath]):
368+
fields (Sequence[google.cloud.firestore_v1.types.FieldPath]):
369369
370370
"""
371371

@@ -376,7 +376,7 @@ class Where(proto.Message):
376376
r"""
377377
378378
Attributes:
379-
path (~.gcf_tests.FieldPath):
379+
path (google.cloud.firestore_v1.types.FieldPath):
380380
381381
op (str):
382382
@@ -395,7 +395,7 @@ class OrderBy(proto.Message):
395395
r"""
396396
397397
Attributes:
398-
path (~.gcf_tests.FieldPath):
398+
path (google.cloud.firestore_v1.types.FieldPath):
399399
400400
direction (str):
401401
"asc" or "desc".
@@ -410,7 +410,7 @@ class Cursor_(proto.Message):
410410
r"""
411411
412412
Attributes:
413-
doc_snapshot (~.gcf_tests.DocSnapshot):
413+
doc_snapshot (google.cloud.firestore_v1.types.DocSnapshot):
414414
one of:
415415
json_values (Sequence[str]):
416416
@@ -462,9 +462,9 @@ class ListenTest(proto.Message):
462462
in the tests before running them.
463463
464464
Attributes:
465-
responses (Sequence[~.firestore.ListenResponse]):
465+
responses (Sequence[google.cloud.firestore_v1.types.ListenResponse]):
466466
467-
snapshots (Sequence[~.gcf_tests.Snapshot]):
467+
snapshots (Sequence[google.cloud.firestore_v1.types.Snapshot]):
468468
469469
is_error (bool):
470470
@@ -483,11 +483,11 @@ class Snapshot(proto.Message):
483483
r"""
484484
485485
Attributes:
486-
docs (Sequence[~.document.Document]):
486+
docs (Sequence[google.cloud.firestore_v1.types.Document]):
487487
488-
changes (Sequence[~.gcf_tests.DocChange]):
488+
changes (Sequence[google.cloud.firestore_v1.types.DocChange]):
489489
490-
read_time (~.timestamp.Timestamp):
490+
read_time (google.protobuf.timestamp_pb2.Timestamp):
491491
492492
"""
493493

@@ -502,9 +502,9 @@ class DocChange(proto.Message):
502502
r"""
503503
504504
Attributes:
505-
kind (~.gcf_tests.DocChange.Kind):
505+
kind (google.cloud.firestore_v1.types.DocChange.Kind):
506506
507-
doc (~.document.Document):
507+
doc (google.cloud.firestore_v1.types.Document):
508508
509509
old_index (int):
510510

packages/google-cloud-firestore/tests/unit/v1/testdata/query-invalid-operator.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"tests": [
33
{
44
"description": "query: invalid operator in Where clause",
5-
"comment": "The |~| operator is not supported.",
5+
"comment": "The |~| operator is not supported.",
66
"query": {
77
"collPath": "projects/projectID/databases/(default)/documents/C",
88
"clauses": [
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"tests": [
3+
{
4+
"description": "set: merge ArrayUnion field",
5+
"comment": "An ArrayUnion value can occur at any depth. In this case,\nthe transform applies to the field path \"b.c\". \"a\" is left alone and remains in the object.",
6+
"set": {
7+
"option": {
8+
"all": true
9+
},
10+
"docRefPath": "projects/projectID/databases/(default)/documents/C/d",
11+
"jsonData": "{\"a\": 1, \"b\": {\"c\": [\"ArrayUnion\", \"foo\", \"bar\"]}}",
12+
"request": {
13+
"database": "projects/projectID/databases/(default)",
14+
"writes": [
15+
{
16+
"update": {
17+
"name": "projects/projectID/databases/(default)/documents/C/d",
18+
"fields": {
19+
"a": {
20+
"integerValue": "1"
21+
}
22+
}
23+
},
24+
"updateMask": {
25+
"fieldPaths": ["a"]
26+
},
27+
"updateTransforms": [
28+
{
29+
"fieldPath": "b.c",
30+
"appendMissingElements": {
31+
"values": [
32+
{
33+
"stringValue": "foo"
34+
},
35+
{
36+
"stringValue": "bar"
37+
}
38+
]
39+
}
40+
}
41+
]
42+
}
43+
]
44+
}
45+
}
46+
}
47+
]
48+
}

0 commit comments

Comments
 (0)