|
30 | 30 | from google.cloud._helpers import _pb_timestamp_to_datetime |
31 | 31 | from google.cloud._helpers import UTC |
32 | 32 | from google.cloud import firestore_v1 as firestore |
| 33 | +from google.cloud.firestore_v1.client import _FIRESTORE_EMULATOR_HOST |
33 | 34 | from test_utils.system import unique_resource_id |
| 35 | +from test_utils.system import EmulatorCreds |
34 | 36 |
|
35 | 37 | from time import sleep |
36 | 38 |
|
|
41 | 43 | DOCUMENT_EXISTS = "Document already exists: " |
42 | 44 | UNIQUE_RESOURCE_ID = unique_resource_id("-") |
43 | 45 |
|
| 46 | +FIRESTORE_EMULATOR = os.getenv(_FIRESTORE_EMULATOR_HOST) is not None |
| 47 | + |
44 | 48 |
|
45 | 49 | @pytest.fixture(scope=u"module") |
46 | 50 | def client(): |
47 | | - credentials = service_account.Credentials.from_service_account_file(FIRESTORE_CREDS) |
48 | | - project = FIRESTORE_PROJECT or credentials.project_id |
| 51 | + if FIRESTORE_EMULATOR: |
| 52 | + credentials = EmulatorCreds() |
| 53 | + project = FIRESTORE_PROJECT |
| 54 | + else: |
| 55 | + credentials = service_account.Credentials.from_service_account_file( |
| 56 | + FIRESTORE_CREDS |
| 57 | + ) |
| 58 | + project = FIRESTORE_PROJECT or credentials.project_id |
49 | 59 | yield firestore.Client(project=project, credentials=credentials) |
50 | 60 |
|
51 | 61 |
|
@@ -126,6 +136,7 @@ def test_create_document_w_subcollection(client, cleanup): |
126 | 136 | assert sorted(child.id for child in children) == sorted(child_ids) |
127 | 137 |
|
128 | 138 |
|
| 139 | +@pytest.mark.skipif(FIRESTORE_EMULATOR, reason="Internal Issue b/137866686") |
129 | 140 | def test_cannot_use_foreign_key(client, cleanup): |
130 | 141 | document_id = "cannot" + UNIQUE_RESOURCE_ID |
131 | 142 | document = client.document("foreign-key", document_id) |
@@ -280,6 +291,7 @@ def test_document_update_w_int_field(client, cleanup): |
280 | 291 | assert snapshot1.to_dict() == expected |
281 | 292 |
|
282 | 293 |
|
| 294 | +@pytest.mark.skipif(FIRESTORE_EMULATOR, reason="Internal Issue b/137867104") |
283 | 295 | def test_update_document(client, cleanup): |
284 | 296 | document_id = "for-update" + UNIQUE_RESOURCE_ID |
285 | 297 | document = client.document("made", document_id) |
@@ -861,6 +873,7 @@ def test_collection_group_queries_filters(client, cleanup): |
861 | 873 | assert found == set(["cg-doc2"]) |
862 | 874 |
|
863 | 875 |
|
| 876 | +@pytest.mark.skipif(FIRESTORE_EMULATOR, reason="Internal Issue b/137865992") |
864 | 877 | def test_get_all(client, cleanup): |
865 | 878 | collection_name = "get-all" + UNIQUE_RESOURCE_ID |
866 | 879 |
|
|
0 commit comments