@@ -307,16 +307,12 @@ def call_step(var: str) -> str:
307307 assert res == "var"
308308
309309 wfs = dbos ._sys_db .get_workflows (gwi )
310- assert len (wfs ) == 2
310+ assert len (wfs ) == 1
311311
312312 wfi1 = dbos ._sys_db .get_workflow_status (wfs [0 ].workflow_id )
313313 assert wfi1
314314 assert wfi1 ["name" ].startswith ("<temp>" )
315315
316- wfi2 = dbos ._sys_db .get_workflow_status (wfs [1 ].workflow_id )
317- assert wfi2
318- assert wfi2 ["name" ].startswith ("<temp>" )
319-
320316 assert txn_counter == 1
321317 assert step_counter == 1
322318
@@ -350,7 +346,7 @@ def test_step(var: str) -> str:
350346 def test_retried_step (var : str ) -> str :
351347 nonlocal retried_step_counter
352348 retried_step_counter += 1
353- raise Exception (var )
349+ raise ValueError (var )
354350
355351 with pytest .raises (Exception ) as exc_info :
356352 test_transaction ("tval" )
@@ -360,12 +356,12 @@ def test_retried_step(var: str) -> str:
360356 test_step ("cval" )
361357 assert "cval" == str (exc_info .value )
362358
363- with pytest .raises (DBOSMaxStepRetriesExceeded ) as exc_info :
359+ with pytest .raises (ValueError ) as exc_info :
364360 test_retried_step ("rval" )
365361
366362 assert txn_counter == 1
367363 assert step_counter == 1
368- assert retried_step_counter == 3
364+ assert retried_step_counter == 1
369365
370366
371367def test_recovery_workflow (dbos : DBOS ) -> None :
@@ -1102,9 +1098,6 @@ def test_bad_wf4(var: str) -> str:
11021098 with pytest .raises (Exception ) as exc_info :
11031099 test_ns_transaction ("h" )
11041100 assert "data item should not be a function" in str (exc_info .value )
1105- with pytest .raises (Exception ) as exc_info :
1106- test_ns_step ("f" )
1107- assert "data item should not be a function" in str (exc_info .value )
11081101 with pytest .raises (Exception ) as exc_info :
11091102 test_ns_wf ("g" )
11101103 assert "data item should not be a function" in str (exc_info .value )
@@ -1645,22 +1638,14 @@ def workflow(x: int) -> int:
16451638async def test_step_without_dbos (dbos : DBOS , config : DBOSConfig ) -> None :
16461639 DBOS .destroy (destroy_registry = True )
16471640
1648- is_dbos_active = False
1649-
16501641 @DBOS .step ()
16511642 def step (x : int ) -> int :
1652- if is_dbos_active :
1653- assert DBOS .workflow_id is not None
1654- else :
1655- assert DBOS .workflow_id is None
1643+ assert DBOS .workflow_id is None
16561644 return x
16571645
16581646 @DBOS .step ()
16591647 async def async_step (x : int ) -> int :
1660- if is_dbos_active :
1661- assert DBOS .workflow_id is not None
1662- else :
1663- assert DBOS .workflow_id is None
1648+ assert DBOS .workflow_id is None
16641649 return x
16651650
16661651 assert step (5 ) == 5
@@ -1672,7 +1657,30 @@ async def async_step(x: int) -> int:
16721657 assert await async_step (5 ) == 5
16731658
16741659 DBOS .launch ()
1675- is_dbos_active = True
16761660
16771661 assert step (5 ) == 5
16781662 assert await async_step (5 ) == 5
1663+
1664+ assert len (DBOS .list_workflows ()) == 0
1665+
1666+
1667+ def test_nested_steps (dbos : DBOS ) -> None :
1668+
1669+ @DBOS .step ()
1670+ def outer_step () -> str :
1671+ return inner_step ()
1672+
1673+ @DBOS .step ()
1674+ def inner_step () -> str :
1675+ id = DBOS .workflow_id
1676+ assert id is not None
1677+ return id
1678+
1679+ @DBOS .workflow ()
1680+ def workflow () -> str :
1681+ return outer_step ()
1682+
1683+ id = workflow ()
1684+ steps = DBOS .list_workflow_steps (id )
1685+ assert len (steps ) == 1
1686+ assert steps [0 ]["function_name" ] == outer_step .__qualname__
0 commit comments