Skip to content

Commit

Permalink
Add docs for running integration tests locally.
Browse files Browse the repository at this point in the history
Fixes #141

PiperOrigin-RevId: 607109376
  • Loading branch information
Xee authors committed Feb 14, 2024
1 parent b0d0d37 commit 170f30a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ ds = xarray.open_dataset(i, engine='ee')

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.

## How to run integration tests

The Xee integration tests only pass on Xee branches (no forks). Please run the
integration tests locally before sending a PR. To run the tests locally,
authenticate using `earthengine authenticate` and run the following:

```bash
USE_ADC_CREDENTIALS=1 python -m unittest xee/ext_integration_test.py
```

## License

This is not an official Google product.
Expand Down
11 changes: 7 additions & 4 deletions xee/ext_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/earthengine',
]
_USE_ADC_CREDENTIALS_KEY = 'USE_ADC_CREDENTIALS'


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


def init_ee_for_tests():
ee.Initialize(
credentials=_read_identity_pool_creds(),
opt_url=ee.data.HIGH_VOLUME_API_BASE_URL,
)
init_params = {
'opt_url': ee.data.HIGH_VOLUME_API_BASE_URL,
}
if not os.environ.get(_USE_ADC_CREDENTIALS_KEY, False):
init_params['credentials'] = _read_identity_pool_creds()
ee.Initialize(**init_params)


class EEBackendArrayTest(absltest.TestCase):
Expand Down

0 comments on commit 170f30a

Please sign in to comment.