-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from materialsproject/fix-compositon-serializ…
…ation Fix oxidation doc composition
- Loading branch information
Showing
3 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from maggma.stores import JSONStore, MemoryStore | ||
|
||
from emmet.builders.materials.oxidation_states import OxidationStatesBuilder | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def fake_materias(test_dir): | ||
entries = JSONStore(test_dir / "LiTiO2_batt.json", key="entry_id") | ||
entries.connect() | ||
|
||
materials_store = MemoryStore(key="material_id") | ||
materials_store.connect() | ||
|
||
for doc in entries.query(): | ||
materials_store.update( | ||
{"material_id": doc["entry_id"], "structure": doc["structure"]} | ||
) | ||
return materials_store | ||
|
||
|
||
def test_oxidation_store(fake_materias): | ||
oxi_store = MemoryStore() | ||
builder = OxidationStatesBuilder( | ||
materials=fake_materias, oxidation_states=oxi_store | ||
) | ||
builder.run() | ||
|
||
assert oxi_store.count() == 6 | ||
assert all([isinstance(d["composition"], dict) for d in oxi_store.query()]) |