Skip to content

Commit 1c3874a

Browse files
authored
Class Decorator Tests (#415)
1 parent 28ed708 commit 1c3874a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_classdecorators.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,3 +911,30 @@ def step(self, x: int) -> int:
911911
DBOS.launch()
912912

913913
assert inst.step(input) == input + input
914+
915+
916+
def test_class_with_only_steps(dbos: DBOS) -> None:
917+
918+
class StepClass:
919+
def __init__(self, x: int) -> None:
920+
self.x = x
921+
922+
@DBOS.step()
923+
def step(self, x: int, expr: Callable[[int, int], int]) -> int:
924+
return expr(self.x, x)
925+
926+
input = 5
927+
inst = StepClass(5)
928+
929+
l = lambda x, y: x + y
930+
931+
@DBOS.workflow()
932+
def test_workflow() -> int:
933+
return inst.step(input, l) + inst.step(input, l)
934+
935+
handle = DBOS.start_workflow(test_workflow)
936+
assert handle.get_result() == input * 4
937+
938+
steps = DBOS.list_workflow_steps(handle.workflow_id)
939+
assert len(steps) == 2
940+
assert steps[1]["output"] == steps[1]["output"] == input * 2

0 commit comments

Comments
 (0)