Skip to content

Commit 9edddfe

Browse files
committed
Update tests
1 parent 1c80a17 commit 9edddfe

1 file changed

Lines changed: 17 additions & 46 deletions

File tree

tests/test_fairstep.py

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from nanopub import Publication
77

88
from conftest import skip_if_nanopub_server_unavailable, read_rdf_test_resource
9-
from fairworkflows import FairStep, namespaces, FairVariable, mark_as_fairstep
10-
from fairworkflows.fairstep import _extract_outputs_from_function
9+
from fairworkflows import FairStep, namespaces, FairVariable, is_fairworkflow
10+
from fairworkflows.fairstep import _extract_outputs_from_function, is_fairstep
1111
from fairworkflows.rdf_wrapper import replace_in_rdf
1212

1313

@@ -245,55 +245,26 @@ def test_shacl_does_not_validate(self):
245245
assert len(step.rdf) == n_triples_before, 'shacl_validate mutated RDF'
246246

247247

248-
def test_mark_as_fairstep():
249-
@mark_as_fairstep(label='test_label', is_manual_task=True)
248+
def test_is_fairstep_decorator():
249+
@is_fairstep(label='test_label')
250250
def add(a: int, b: int) -> int:
251251
"""
252252
Computational step adding two ints together.
253253
"""
254254
return a + b
255255

256-
assert add(40, 2) == 42, 'Function execution does not work as expected'
257-
step = FairStep.from_function(add)
258-
assert str(step.label) == 'test_label'
259-
assert step.is_manual_task
260-
assert step.is_pplan_step
261-
assert not step.is_script_task
262-
assert 'def add(a: int, b: int) -> int:' in str(step.description)
263-
assert 'Computational step adding two ints together.' in str(step.description)
264-
assert isinstance(step, FairStep)
265-
assert set(step.inputs) == {FairVariable('a', 'int'), FairVariable('b', 'int')}
266-
assert step.outputs[0] == FairVariable('add_output1', 'int')
267-
268-
269-
def test_mark_as_fairstep_arguments_no_type_hinting():
270-
with pytest.raises(ValueError):
271-
@mark_as_fairstep(label='test_label', is_manual_task=True)
272-
def add(a, b) -> int: # Note the missing type hinting for arguments
273-
"""
274-
Computational step adding two ints together.
275-
"""
276-
return a + b
277-
278-
279-
def test_mark_as_fairstep_return_no_type_hinting():
280-
with pytest.raises(ValueError):
281-
@mark_as_fairstep(label='test_label', is_manual_task=True)
282-
def add(a: int, b: int): # Note the missing type hinting for return
283-
"""
284-
Computational step adding two ints together.
285-
"""
286-
return a + b
256+
assert hasattr(add(1,2), '_fairstep')
287257

288-
289-
def test_mark_as_fairstep_validation_fails():
290-
with pytest.raises(AssertionError):
291-
@mark_as_fairstep(is_manual_task=True) # There is no label, so it won't validate
292-
def add(a: int, b: int) -> int:
293-
"""
294-
Computational step adding two ints together.
295-
"""
296-
return a + b
258+
# step = FairStep.from_function(add)
259+
# assert str(step.label) == 'test_label'
260+
# assert step.is_manual_task
261+
# assert step.is_pplan_step
262+
# assert not step.is_script_task
263+
# assert 'def add(a: int, b: int) -> int:' in str(step.description)
264+
# assert 'Computational step adding two ints together.' in str(step.description)
265+
# assert isinstance(step, FairStep)
266+
# assert set(step.inputs) == {FairVariable('a', 'int'), FairVariable('b', 'int')}
267+
# assert step.outputs[0] == FairVariable('add_output1', 'int')
297268

298269

299270
def test_extract_outputs_from_function_multiple_outputs():
@@ -305,5 +276,5 @@ def divmod(a: int, b: int) -> Tuple[int, int]:
305276
return a // b, a % b
306277

307278
result = _extract_outputs_from_function(divmod)
308-
assert set(result) == {FairVariable('divmod_output1', 'int'),
309-
FairVariable('divmod_output2', 'int')}
279+
assert set(result) == {FairVariable('divmod-output1', 'int'),
280+
FairVariable('divmod-output2', 'int')}

0 commit comments

Comments
 (0)