Skip to content

Commit 170f30a

Browse files
author
Xee authors
committed
Add docs for running integration tests locally.
Fixes #141 PiperOrigin-RevId: 607109376
1 parent b0d0d37 commit 170f30a

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ ds = xarray.open_dataset(i, engine='ee')
9292

9393
See [examples](https://github.com/google/Xee/tree/main/examples) or [docs](https://github.com/google/Xee/tree/main/docs) for more uses and integrations.
9494

95+
## How to run integration tests
96+
97+
The Xee integration tests only pass on Xee branches (no forks). Please run the
98+
integration tests locally before sending a PR. To run the tests locally,
99+
authenticate using `earthengine authenticate` and run the following:
100+
101+
```bash
102+
USE_ADC_CREDENTIALS=1 python -m unittest xee/ext_integration_test.py
103+
```
104+
95105
## License
96106

97107
This is not an official Google product.

xee/ext_integration_test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
'https://www.googleapis.com/auth/cloud-platform',
4040
'https://www.googleapis.com/auth/earthengine',
4141
]
42+
_USE_ADC_CREDENTIALS_KEY = 'USE_ADC_CREDENTIALS'
4243

4344

4445
def _read_identity_pool_creds() -> identity_pool.Credentials:
@@ -50,10 +51,12 @@ def _read_identity_pool_creds() -> identity_pool.Credentials:
5051

5152

5253
def init_ee_for_tests():
53-
ee.Initialize(
54-
credentials=_read_identity_pool_creds(),
55-
opt_url=ee.data.HIGH_VOLUME_API_BASE_URL,
56-
)
54+
init_params = {
55+
'opt_url': ee.data.HIGH_VOLUME_API_BASE_URL,
56+
}
57+
if not os.environ.get(_USE_ADC_CREDENTIALS_KEY, False):
58+
init_params['credentials'] = _read_identity_pool_creds()
59+
ee.Initialize(**init_params)
5760

5861

5962
class EEBackendArrayTest(absltest.TestCase):

0 commit comments

Comments
 (0)