-
Notifications
You must be signed in to change notification settings - Fork 62
/
test_provenance.py
51 lines (38 loc) · 1.35 KB
/
test_provenance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from datetime import datetime
import pytest
from pymatgen.core import Element, Lattice, Structure
from pymatgen.util.provenance import Author, HistoryNode, StructureNL
from emmet.core.provenance import Database, ProvenanceDoc
@pytest.fixture
def structure():
test_latt = Lattice.cubic(3.0)
test_struc = Structure(lattice=test_latt, species=["Fe"], coords=[[0, 0, 0]])
return test_struc
@pytest.fixture
def snls(structure):
docs = [
StructureNL(
structure,
authors=[Author("test{i}", "test@test.com").as_dict()],
history=[HistoryNode("nothing", "url.com", {})],
created_at=datetime.utcnow(),
).as_dict()
for i in range(3)
]
docs[0]["snl_id"] = "icsd-2"
docs[1]["snl_id"] = "user-1"
docs[2]["snl_id"] = "pf-3"
return docs
def test_from_snls(snls):
doc = ProvenanceDoc.from_SNLs(material_id="mp-3", snls=snls)
assert isinstance(doc, ProvenanceDoc)
assert doc.property_name == "provenance"
assert doc.material_id == "mp-3"
assert doc.theoretical is True
assert doc.database_IDs == {
Database.ICSD: ["icsd-2"],
Database.Pauling_Files: ["pf-3"],
}
# Test experimental detection
snls[0]["about"]["history"][0]["experimental"] = True
assert ProvenanceDoc.from_SNLs(material_id="mp-3", snls=snls).theoretical is False