Skip to content

Commit

Permalink
better maxar authentication handling
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyhq committed Nov 22, 2024
1 parent 878d275 commit e2c66c9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/coincident/search/stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
except maxar_platform.session.NoSessionCredentials:
msg_noauth = "Unable to authenticate with Maxar API. Please set MAXAR_API_KEY environment variable."
warnings.warn(msg_noauth, stacklevel=2)
except maxar_platform.exceptions.UnAuthorizedException:
msg_noauth = (
"Unable to authenticate with Maxar API. Please check MAXAR_API_KEY is valid."
)
warnings.warn(msg_noauth, stacklevel=2)


def _filter_assets(assets: gpd.GeoDataFrame) -> dict[str, str]:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
# Decorate tests requiring internet (slow & flaky)
network = pytest.mark.network

try:
import maxar_platform.discovery # noqa: F401
except: # noqa: E722
maxar_authenticated = pytest.mark.skip(
reason="unable to authenticate with maxar API"
)


@pytest.fixture
def aoi():
Expand Down Expand Up @@ -75,6 +82,7 @@ def test_cascading_search(aoi):

# TODO: add more assertions / tests for this section
@network
@maxar_authenticated
@pytest.mark.filterwarnings("ignore:Server does not conform")
def test_maxar_search(aoi):
gf = coincident.search.search(
Expand All @@ -91,6 +99,7 @@ def test_maxar_search(aoi):


@network
@maxar_authenticated
def test_maxar_large_aoi(large_aoi):
gf = coincident.search.search(
dataset="maxar",
Expand Down

0 comments on commit e2c66c9

Please sign in to comment.