-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented external API to run functions with dependency being injec…
…ted (#12) * Add external API on aioclock to run any task with deps injected * Add test
- Loading branch information
1 parent
0cf0c91
commit 9d4edf0
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
from aioclock import AioClock, Depends, Once, run_with_injected_deps | ||
|
||
app = AioClock() | ||
|
||
|
||
def some_dependency(): | ||
return 1 | ||
|
||
|
||
@app.task(trigger=Once()) | ||
async def main(bar: int = Depends(some_dependency)): | ||
print("Hello World") | ||
return bar | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_run_manual(): | ||
foo = await run_with_injected_deps(main) | ||
assert foo == 1 |