Skip to content

Commit 32714d3

Browse files
add tests for summary warnings
1 parent 4364180 commit 32714d3

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

tests/materials/test_summary.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pymatgen.analysis.magnetism import Ordering
88

99
from mp_api.client.routes.materials.summary import SummaryRester
10+
from mp_api.client.core.client import MPRestWarning, MPRestError
1011

1112
excluded_params = [
1213
"include_gnome",
@@ -44,7 +45,8 @@
4445
} # type: dict
4546

4647
custom_field_tests = {
47-
"material_ids": ["mp-149"],
48+
"material_ids": ["mp-149","mp-13"],
49+
"material_ids": "mp-149",
4850
"formula": "SiO2",
4951
"chemsys": "Si-O",
5052
"elements": ["Si", "O"],
@@ -112,3 +114,20 @@ def test_list_like_input():
112114

113115
with pytest.raises(ValueError, match="retrieve all data first and then filter"):
114116
_ = search_method(crystal_system=list(CrystalSystem))
117+
118+
@pytest.mark.skipif(os.getenv("MP_API_KEY") is None, reason="No API key found.")
119+
def test_warning_messages():
120+
121+
search_method = SummaryRester().search
122+
123+
with pytest.warns(MPRestWarning,match="You have specified fields used by"):
124+
_ = search_method(nelements=10)
125+
126+
with pytest.raises(MPRestError,match="You have specified fields known to both"):
127+
_ = search_method(nelements=10,num_elements=11)
128+
129+
with pytest.raises(MPRestError,match="You have specified the following kwargs which are unknown to"):
130+
_ = search_method(apples = "oranges")
131+
132+
with pytest.raises(MPRestError,match="not a valid property"):
133+
_ = search_method(num_elements=10, has_props=["apples"])

0 commit comments

Comments
 (0)