Skip to content

Commit

Permalink
feat: add attribute __step_params__
Browse files Browse the repository at this point in the history
  • Loading branch information
mic1on committed Jul 10, 2024
1 parent 8ce3266 commit 30049b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/onestep/onestep.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def __init__(self,
}

def __call__(self, func, *_args, **_kwargs):
func.__step_params__ = self.params
if iscoroutinefunction(func) or isasyncgenfunction(func):
os = AsyncOneStep(fn=func, **self.params)
else:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_step_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from onestep import step
from onestep.broker import MemoryBroker


@pytest.fixture
def broker():
return MemoryBroker()


def test_func(broker):

@step(from_broker=broker, name="do_some_thing")
def do_some_thing(message):
...
assert do_some_thing.__step_params__ is not None

assert do_some_thing.__step_params__["from_broker"] == broker
assert do_some_thing.__step_params__["name"] == "do_some_thing"

0 comments on commit 30049b8

Please sign in to comment.