Skip to content

Commit b4bdb53

Browse files
committed
Add test for publishing of retro prov
1 parent 90367a8 commit b4bdb53

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

tests/test_fairworkflow.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,12 @@ def test_publish_as_nanopub_no_modifications(self, mock_publish, test_workflow):
308308
assert mock_publish.call_count == 0
309309
assert pubinfo['nanopub_uri'] is None
310310

311-
def test_workflow_construction_and_execution(self):
311+
@mock.patch('fairworkflows.rdf_wrapper.NanopubClient.publish')
312+
def test_workflow_construction_and_execution(self, mock_publish):
312313
"""
313314
Construct a workflow using the is_fairstep and is_fairworkflow decorators
314-
and check that execution and returned provenance is as expected.
315+
and check that execution and returned provenance is as expected. Then
316+
(mock) publishes the provenance and checks the entities are updated.
315317
"""
316318
@is_fairstep(label='Addition')
317319
def add(a:float, b:float) -> float:
@@ -358,6 +360,21 @@ def my_workflow(in1, in2, in3):
358360
assert isinstance(step_prov, StepRetroProv)
359361
assert step_prov.step in fw._steps.values()
360362

363+
test_published_uris = [
364+
'www.example.org/published1#prov',
365+
'www.example.org/published2#prov',
366+
'www.example.org/published3#prov',
367+
'www.example.org/published4#prov',
368+
'www.example.org/published5#prov'
369+
]
370+
mock_publish.side_effect = [{'concept_uri': uri} for uri in test_published_uris]
371+
372+
prov.publish_as_nanopub()
373+
assert mock_publish.call_count == 5 # 1 workflow, 4 steps
374+
375+
for uri in test_published_uris[:4]:
376+
assert (None, namespaces.PROV.hasMember, rdflib.URIRef(uri)) in prov._rdf
377+
361378
def test_workflow_complex_serialization(self):
362379
class OtherType:
363380
def __init__(self, message):

0 commit comments

Comments
 (0)