Skip to content

Commit

Permalink
add more tests for endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Sep 28, 2024
1 parent 5540253 commit d2a1fbc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/test_mprester.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,14 @@ def test_get_api_key_from_settings(self, monkeypatch: pytest.MonkeyPatch):
get "PMG_MAPI_KEY" from "SETTINGS".
"""
monkeypatch.delenv("MP_API_KEY", raising=False)
assert os.environ.get("MP_API_KEY") is None

# patch pymatgen.core.SETTINGS to contain PMG_MAPI_KEY
monkeypatch.setitem(SETTINGS, "PMG_MAPI_KEY", FAKE_MP_API_KEY)

# create MPRester and check that it picked up the API key from SETTINGS
assert MPRester().api_key == FAKE_MP_API_KEY

def test_get_default_endpoint(self, monkeypatch: pytest.MonkeyPatch):
monkeypatch.delenv("MP_API_ENDPOINT", raising=False)
assert os.environ.get("MP_API_ENDPOINT") is None
assert MPRester().endpoint == "https://api.materialsproject.org/"

0 comments on commit d2a1fbc

Please sign in to comment.