Skip to content

Commit

Permalink
Add TSV test and minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Jan 5, 2024
1 parent 2081f47 commit 1bf8756
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,21 +454,18 @@ def _basic_round_trip(self, key: str):
)

with TemporaryDirectory() as dir:
directory = Path(dir)
path = directory.joinpath("test.sssom.x")
path_str = str(path)
path = Path(dir).joinpath("test.sssom.x")
with path.open("w") as file:
write_func(msdf, file)

reconstituted_msdf = parse_func(path_str)
reconstituted_msdf = parse_func(path)
reconstituted_msdf.clean_prefix_map(strict=True)

test_meta = {
"mapping_set_title": "A title",
"license": "https://w3id.org/sssom/license/test",
}

reconstituted_msdf_with_meta = parse_func(path_str, meta=test_meta)
reconstituted_msdf_with_meta = parse_func(path, meta=test_meta)
reconstituted_msdf_with_meta.clean_prefix_map(strict=True)

# Ensure the prefix maps are equal after json parsing and cleaning
Expand Down Expand Up @@ -497,10 +494,14 @@ def _basic_round_trip(self, key: str):
# to the MappingSet if they are not present, but not updated if they are already present.
self.assertEqual(combine_meta, reconstituted_msdf_with_meta.metadata)

def test_round_trip_json_tsv(self):
"""Test JSON => TSV using parse()."""
def test_round_trip_json(self):
"""Test writing then reading JSON."""
self._basic_round_trip("json")

def test_round_trip_rdf_tsv(self):
"""Test RDF => TSV using parse()."""
def test_round_trip_rdf(self):
"""Test writing then reading RDF."""
self._basic_round_trip("rdf")

def test_round_trip_tsv(self):
"""Test writing then reading TSV."""
self._basic_round_trip("tsv")

0 comments on commit 1bf8756

Please sign in to comment.