Skip to content

Commit c82302d

Browse files
committed
- Add: TestWrite.test_missing_entries()
1 parent 91d08b8 commit c82302d

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

tests/test_writers.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import unittest
66
from typing import Any, Dict
77

8+
import curies
89
import pandas as pd
910
from curies import Converter
1011

@@ -191,3 +192,68 @@ def test_write_sssom_ontoportal_json(self):
191192
self.mapping_count,
192193
f"{path} has the wrong number of mappings.",
193194
)
195+
196+
# TODO: Determine assertions that should pass
197+
# TODO: Fix failing assertions that should pass
198+
# TODO: before merging, remove pass/fail comments at end of assertion lines
199+
def test_missing_entries(self):
200+
"""Test to make sure that missing entires do not appear."""
201+
tmp_file = os.path.join(test_out_dir, "test_missing_entries.sssom.tsv")
202+
df = pd.DataFrame(
203+
[
204+
{
205+
"subject_id": "Orphanet:58",
206+
"subject_label": "Alexander disease",
207+
"predicate_id": "skos:exactMatch",
208+
"object_id": "icd11.foundation:2023359698",
209+
"object_label": "Alexander disease",
210+
"mapping_justification": "semapv:UnspecifiedMatching",
211+
}
212+
]
213+
)
214+
metadata = {
215+
"creator_id": "orcid:0000-0002-2906-7319",
216+
"curie_map": {
217+
"MONDO": "http://purl.obolibrary.org/obo/MONDO_",
218+
"Orphanet": "http://www.orpha.net/ORDO/Orphanet_",
219+
"icd11.foundation": "http://id.who.int/icd/entity/",
220+
"oboInOwl": "http://www.geneontology.org/formats/oboInOwl#",
221+
"orcid": "https://orcid.org/",
222+
"owl": "http://www.w3.org/2002/07/owl#",
223+
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
224+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
225+
"semapv": "https://w3id.org/semapv/",
226+
"skos": "http://www.w3.org/2004/02/skos/core#",
227+
"sssom": "https://w3id.org/sssom/",
228+
},
229+
"license": "http://w3id.org/sssom/license/unspecified",
230+
"mapping_provider": "https://www.orpha.net/",
231+
}
232+
233+
# When passing Converter
234+
msdf: MappingSetDataFrame = MappingSetDataFrame(
235+
converter=curies.Converter.from_prefix_map(metadata["curie_map"]),
236+
df=df,
237+
metadata=metadata,
238+
)
239+
self.assertIn("curie_map", msdf.metadata) # pass
240+
self.assertIn("icd11.foundation", msdf.metadata["curie_map"]) # pass
241+
self.assertIn("icd11.foundation", msdf.prefix_map) # pass
242+
with open(tmp_file, "w") as f:
243+
write_table(msdf, f)
244+
msdf2 = parse_sssom_table(tmp_file)
245+
self.assertIn("curie_map", msdf2.metadata) # fail
246+
self.assertIn("icd11.foundation", msdf2.metadata["curie_map"]) # KeyError
247+
self.assertIn("icd11.foundation", msdf2.prefix_map) # pass
248+
249+
# When no passed Converter
250+
msdf: MappingSetDataFrame = MappingSetDataFrame(df=df, metadata=metadata)
251+
self.assertIn("curie_map", msdf.metadata) # pass
252+
self.assertIn("icd11.foundation", msdf.metadata["curie_map"]) # pass
253+
self.assertIn("icd11.foundation", msdf.prefix_map) # fail
254+
with open(tmp_file, "w") as f:
255+
write_table(msdf, f)
256+
msdf2 = parse_sssom_table(tmp_file)
257+
self.assertIn("curie_map", msdf2.metadata) # fail
258+
self.assertIn("icd11.foundation", msdf2.metadata["curie_map"]) # KeyError
259+
self.assertIn("icd11.foundation", msdf2.prefix_map) # fail

0 commit comments

Comments
 (0)