From 709c10d3a0e63617fdbe98f017e3f17db46c4a7d Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Mon, 16 Oct 2023 21:08:51 -0500 Subject: [PATCH 1/3] Fix test_auth_environ_raises integration test --- tests/integration/test_api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index c449c358..1a3b2ed9 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -91,6 +91,16 @@ def test_auth_environ(): def test_auth_environ_raises(monkeypatch): + # Temporarily remove any existing authentication and make it so + # future attempts at authentication don't work monkeypatch.setattr(earthaccess.__auth__, "authenticated", False) + + def bad_login(*args, **kwargs): + raise RuntimeError("Can't login") + + monkeypatch.setattr(earthaccess.Auth, "login", bad_login) + + # Ensure `earthaccess.auth_environ()` raises an informative error + # when not authenticated with pytest.raises(RuntimeError, match="authenticate"): earthaccess.auth_environ() From 5517c5689816c69093b44160bed1b81d9dcc9f25 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Mon, 16 Oct 2023 21:15:02 -0500 Subject: [PATCH 2/3] Less --- tests/integration/test_api.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index 1a3b2ed9..b6bce6b4 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -91,14 +91,9 @@ def test_auth_environ(): def test_auth_environ_raises(monkeypatch): - # Temporarily remove any existing authentication and make it so - # future attempts at authentication don't work - monkeypatch.setattr(earthaccess.__auth__, "authenticated", False) - - def bad_login(*args, **kwargs): - raise RuntimeError("Can't login") - - monkeypatch.setattr(earthaccess.Auth, "login", bad_login) + # Temporarily ensure `earthaccess.__auth__` always returns a + # new, unauthenticated `earthaccess.Auth`` instance + monkeypatch.setattr(earthaccess, "__auth__", earthaccess.Auth()) # Ensure `earthaccess.auth_environ()` raises an informative error # when not authenticated From 234f9af998a0829f9356ffe5565e190e0e9dbcd3 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Tue, 17 Oct 2023 10:24:18 -0500 Subject: [PATCH 3/3] Update comment Co-authored-by: Matt Fisher --- tests/integration/test_api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_api.py b/tests/integration/test_api.py index b6bce6b4..bde37b05 100644 --- a/tests/integration/test_api.py +++ b/tests/integration/test_api.py @@ -91,8 +91,9 @@ def test_auth_environ(): def test_auth_environ_raises(monkeypatch): - # Temporarily ensure `earthaccess.__auth__` always returns a - # new, unauthenticated `earthaccess.Auth`` instance + # Ensure `earthaccess.__auth__` always returns a new, + # unauthenticated `earthaccess.Auth` instance, bypassing + # automatic auth behavior monkeypatch.setattr(earthaccess, "__auth__", earthaccess.Auth()) # Ensure `earthaccess.auth_environ()` raises an informative error