Open nsbgn opened 1 year ago
The above tests are now implemented in [test.py] using the nose2 testing framework. I also tried pytest and plain unittest
, but I found that these were more of a hassle to use for generating separate tests for each node/workflow (which helps to know where the error occurs). unittest
's TestCase.subTest
came close, but would have required more boilerplate. In the end, I wrote the @nodes
decorator to make use of node2's test generator functionality, which ends up looking like this:
@nodes(graph.subjects(RDF.type, TOOLS.ToolCombination))
def test_supertool_blank_nodes_never_reused(self, tool: Node):
for step in graph.objects(tool, WF.edge):
self.assertEqual([tool], list(graph.subjects(WF.edge, step)))
This seems to me the cleanest way to go about it. Please feel free to add tests in the same style, since clearly, there are a great number of tests we could possibly do and it is hard to know which are important.
In fact, it's probably wise to use a dedicated RDF schema validator for this purpose, as I mentioned in the comment at the top of the test file; cf. https://www.w3.org/2012/12/rdf-val/SOTA; http://book.validatingrdf.com/; https://shex.io/shex-primer/; https://www.w3.org/TR/shacl/. We can do that later, but for now, this should suffice.
148 out of the 627 tests currently fail. I will look into the reason later.
We need some tests for validating that our ontologies and workflow files are sane. This issue will track the tests that make sense to have.
wf:edge
) in a workflow should have a tool (indicated bywf:applicationOf
).