From 3cfe2fe52ae5658d050bc53762272c499ee712cb Mon Sep 17 00:00:00 2001 From: David Fielding Date: Tue, 17 Mar 2026 09:52:29 -0400 Subject: [PATCH 1/5] Test for non-iterable value bug in index() routine. [SUBMISSION-76] David --- .../tests/test_workflow_index_string.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 submit_ce/ui/workflow/tests/test_workflow_index_string.py diff --git a/submit_ce/ui/workflow/tests/test_workflow_index_string.py b/submit_ce/ui/workflow/tests/test_workflow_index_string.py new file mode 100644 index 0000000..2342d74 --- /dev/null +++ b/submit_ce/ui/workflow/tests/test_workflow_index_string.py @@ -0,0 +1,18 @@ +"""Test to trigger index string bug in __init__.py""" +import pytest +from submit_ce.ui.workflow import WorkflowDefinition +from submit_ce.ui.workflow.stages import Stage + +class X(Stage): + label = "X"; endpoint = "x" + def is_complete(self, sub): return True + def incomplete(self, sub): return [] + +class Y(Stage): + label = "Y"; endpoint = "y" + def is_complete(self, sub): return True + def incomplete(self, sub): return [] + +def test_index_by_string(): + wf = WorkflowDefinition("WF", order=[X(), Y()], confirmation=Y()) + assert wf.index("Y") == 1 From e7133073269a562383ca06e55c4e8818c80013eb Mon Sep 17 00:00:00 2001 From: David Fielding Date: Tue, 17 Mar 2026 09:53:54 -0400 Subject: [PATCH 2/5] Additional test to improve coverage. [SUBMISSION-76] David --- .../workflow/tests/test_stage_from_endpoint.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 submit_ce/ui/workflow/tests/test_stage_from_endpoint.py diff --git a/submit_ce/ui/workflow/tests/test_stage_from_endpoint.py b/submit_ce/ui/workflow/tests/test_stage_from_endpoint.py new file mode 100644 index 0000000..d0755d8 --- /dev/null +++ b/submit_ce/ui/workflow/tests/test_stage_from_endpoint.py @@ -0,0 +1,16 @@ +"""Test getting stage from endpoint.""" +# tests/ui/workflow/test_stage_from_endpoint.py +import pytest +from submit_ce.ui.workflow import WorkflowDefinition +from submit_ce.ui.workflow.stages import Stage + +class P(Stage): + endpoint = "p"; label = "P" + def is_complete(self, sub): return True + def incomplete(self, sub): return [] + +def test_stage_from_endpoint_and_error(): + wf = WorkflowDefinition("WF", order=[P()], confirmation=P()) + assert type(wf.stage_from_endpoint("p")).__name__ == "P" + with pytest.raises(ValueError): + wf.stage_from_endpoint("nope") From 4e1f53478aa8f1321b118c29faa658236718e6db Mon Sep 17 00:00:00 2001 From: David Fielding Date: Tue, 17 Mar 2026 09:56:12 -0400 Subject: [PATCH 3/5] Test that must_see works as expected. Additional test to improve coverage. [SUBMISSION-76] David --- .../ui/workflow/tests/test_workflow_must_see.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 submit_ce/ui/workflow/tests/test_workflow_must_see.py diff --git a/submit_ce/ui/workflow/tests/test_workflow_must_see.py b/submit_ce/ui/workflow/tests/test_workflow_must_see.py new file mode 100644 index 0000000..4457a14 --- /dev/null +++ b/submit_ce/ui/workflow/tests/test_workflow_must_see.py @@ -0,0 +1,17 @@ +"""Test behavior when must seen is set""" +import pytest +from submit_ce.ui.workflow import ReplacementWorkflow +from submit_ce.ui.workflow.processor import WorkflowProcessor + +@pytest.mark.usefixtures("app") +def test_must_see_forces_visitation(sub_metadata): + wf = ReplacementWorkflow + proc = WorkflowProcessor(workflow=wf, submission=sub_metadata) + + # First stage must be seen even if predicates are satisfied + first = proc.current_stage() + assert type(first).__name__ == "VerifyUser" + + # After marking seen, the processor should advance + proc.mark_seen(first) + assert type(proc.current_stage()).__name__ != "VerifyUser" From 487b3ea2d53e3329c11443410cbcab74f54f4775 Mon Sep 17 00:00:00 2001 From: David Fielding Date: Tue, 17 Mar 2026 15:26:14 -0400 Subject: [PATCH 4/5] Test blocked step. --- .../workflow/tests/test_workflow_blocked.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 submit_ce/ui/workflow/tests/test_workflow_blocked.py diff --git a/submit_ce/ui/workflow/tests/test_workflow_blocked.py b/submit_ce/ui/workflow/tests/test_workflow_blocked.py new file mode 100644 index 0000000..e270e7f --- /dev/null +++ b/submit_ce/ui/workflow/tests/test_workflow_blocked.py @@ -0,0 +1,22 @@ +"""Test blocked on finalize.""" +import pytest +from submit_ce.ui.workflow import WorkflowDefinition +from submit_ce.ui.workflow.stages import ( + VerifyUser, Agreement, License, Classification, + FileUpload, ReviewFiles, Process, Metadata, FinalPreview, Confirm +) +from submit_ce.ui.workflow.processor import WorkflowProcessor + +@pytest.mark.usefixtures("app") +def test_blocked_rules(sub_metadata): + wf = WorkflowDefinition( + "WF", + order=[VerifyUser(), Agreement(), License(), Classification(), + FileUpload(), ReviewFiles(), Process(), Metadata(), FinalPreview()], + confirmation=Confirm(), + ) + proc = WorkflowProcessor(workflow=wf, submission=sub_metadata) + + # Confirmation is blocked by FinalPreview (not finalized yet) + blocks = dict(proc.blocked(wf.confirmation)) + assert "FinalPreview" in blocks From cafc76f17ce18b7d170b2db4391c40eeb3f94a1c Mon Sep 17 00:00:00 2001 From: David Fielding Date: Tue, 17 Mar 2026 15:38:44 -0400 Subject: [PATCH 5/5] Fix bug with non-iterable value in index() routine. [SUBMISSION-76] David --- submit_ce/ui/workflow/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submit_ce/ui/workflow/__init__.py b/submit_ce/ui/workflow/__init__.py index ad22090..4c95dc6 100644 --- a/submit_ce/ui/workflow/__init__.py +++ b/submit_ce/ui/workflow/__init__.py @@ -62,7 +62,7 @@ def index(self, stage: Union[type, Stage, str]) -> int: raise ValueError(f"{stage} not In workflow") if isinstance(stage, str): # it could be classname, stage label - for idx, wstg in self.order: + for idx, wstg in enumerate(self.order): if(wstg.label == stage or wstg.__class__.__name__ == stage): return idx