Skip to content

Commit

Permalink
add one test
Browse files Browse the repository at this point in the history
  • Loading branch information
samwaseda committed Jan 10, 2025
1 parent b6c61b2 commit 66bf6a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pyiron_ontology/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def get_triples(data, EX):
full_key = data["label"] + f".{io_}." + key
label = EX[full_key]
graph.add((label, RDFS.label, Literal(full_key)))
graph.add((label, RDF.type, d["uri"]))
graph.add((label, RDF.value, Literal(d["value"])))
if d["uri"]:
graph.add((label, RDF.type, d["uri"]))
if d["value"]:
graph.add((label, RDF.value, Literal(d["value"])))
graph.add((label, EX[io_[:-1] + "Of"], EX[data["label"]]))
if d["units"] is not None:
graph.add((label, EX.hasUnits, EX[d["units"]]))
Expand Down
12 changes: 11 additions & 1 deletion tests/unit/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import unittest
from pyiron_ontology.parser import get_inputs_and_outputs
from pyiron_ontology.parser import get_inputs_and_outputs, get_triples
from pyiron_workflow import Workflow
from semantikon.typing import u
from rdflib import Namespace


@Workflow.wrap.as_function_node("speed")
Expand All @@ -19,6 +20,15 @@ def test_parser(self):
for label in ["inputs", "outputs", "function", "label"]:
self.assertIn(label, output_dict)

def test_triples(self):
EX = Namespace("http://example.org/")
speed = calculate_speed()
data = get_inputs_and_outputs(speed)
graph = get_triples(data, EX)
self.assertGreater(
len(list(graph.triples((None, EX.hasUnits, EX["meter/second"])))), 0
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 66bf6a7

Please sign in to comment.