Skip to content

Commit

Permalink
Fix MPRester tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyue Ping Ong committed Sep 22, 2023
1 parent 8a9f96c commit d363731
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tests/ext/test_matproj.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import os
import random
import re
from unittest.mock import patch
Expand Down Expand Up @@ -35,16 +34,11 @@
skip_mprester_tests = True


PMG_MAPI_KEY = SETTINGS.get("PMG_MAPI_KEY")
if os.getenv("CI") and PMG_MAPI_KEY and not 15 <= len(PMG_MAPI_KEY) <= 20:
msg = f"Invalid legacy PMG_MAPI_KEY, should be 15-20 characters, got {len(PMG_MAPI_KEY)}"
if len(PMG_MAPI_KEY) == 32:
msg += " (this looks like a new API key)"
raise ValueError(msg)
PMG_MAPI_KEY = SETTINGS.get("PMG_MAPI_KEY", "")


@pytest.mark.skipif(
skip_mprester_tests or (not len(PMG_MAPI_KEY) <= 20),
skip_mprester_tests or (not 10 < len(PMG_MAPI_KEY) <= 20),
reason="Legacy PMG_MAPI_KEY environment variable not set or MP API is down.",
)
class TestMPResterOld(PymatgenTest):
Expand Down Expand Up @@ -528,7 +522,7 @@ def test_api_key_is_none(self):


@pytest.mark.skipif(
skip_mprester_tests or not PMG_MAPI_KEY,
skip_mprester_tests or (not len(PMG_MAPI_KEY) > 20),
reason="PMG_MAPI_KEY environment variable not set or MP API is down.",
)
class TestMPResterNewBasic:
Expand Down

0 comments on commit d363731

Please sign in to comment.