diff --git a/tests/test_conversion.py b/tests/test_conversion.py index faeae644..7f145cd7 100644 --- a/tests/test_conversion.py +++ b/tests/test_conversion.py @@ -15,6 +15,7 @@ from sssom.sssom_document import MappingSetDocument from sssom.util import MappingSetDataFrame, to_mapping_set_dataframe from sssom.writers import ( + to_fhir_json, to_json, to_ontoportal_json, to_owl_graph, @@ -31,6 +32,7 @@ class SSSOMReadWriteTestSuite(unittest.TestCase): """A test case for conversion utilities.""" + # TODO: teardown def test_conversion(self): """Run all conversion tests.""" test_cases = get_all_test_cases() @@ -51,17 +53,19 @@ def test_conversion(self): test.ct_data_frame_rows, f"Wrong number of mappings in MappingSet of {test.filename}", ) - logging.info("Testing OWL export") - self._test_to_owl_graph(mdoc, test) - logging.info("Testing RDF export") - self._test_to_rdf_graph(mdoc, test) - logging.info("Testing CSV export") - self._test_to_dataframe(mdoc, test) - logging.info("Testing JSON export") - self._test_to_json_dict(mdoc, test) - self._test_to_json(mdoc, test) - logging.info("Testing ontoportal JSON export") - self._test_to_ontoportal_json(mdoc, test) + # logging.info("Testing OWL export") + # self._test_to_owl_graph(mdoc, test) + # logging.info("Testing RDF export") + # self._test_to_rdf_graph(mdoc, test) + # logging.info("Testing CSV export") + # self._test_to_dataframe(mdoc, test) + # logging.info("Testing JSON export") + # self._test_to_json_dict(mdoc, test) + # self._test_to_json(mdoc, test) + # logging.info("Testing ontoportal JSON export") + # self._test_to_ontoportal_json(mdoc, test) + # logging.info("Testing fhir_json JSON export") + self._test_to_fhir_json(mdoc, test) def _test_to_owl_graph(self, mdoc, test): msdf = to_mapping_set_dataframe(mdoc) @@ -85,6 +89,13 @@ def _test_to_json(self, mdoc, test: SSSOMTestCase): with open(test.get_out_file("json"), "w") as file: write_json(msdf, file, serialisation="json") + def _test_to_fhir_json(self, mdoc, test: SSSOMTestCase): + """Test writing as FHIR ConceptMap JSON. + todo: could add more test cases, but kinda redundant w/ test_write_sssom_fhir()""" + msdf = to_mapping_set_dataframe(mdoc) + d = to_fhir_json(msdf) + self.assertEqual(len(d["group"][0]["element"]), test.ct_data_frame_rows, "wrong number of mappings.") + def _test_to_ontoportal_json(self, mdoc, test: SSSOMTestCase): msdf = to_mapping_set_dataframe(mdoc) jsonob = to_ontoportal_json(msdf)