-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
69 deletions.
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
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 |
---|---|---|
@@ -1,23 +1,37 @@ | ||
# from typing import Annotated | ||
from typing import Annotated | ||
|
||
# from ididi import Graph, Ignore | ||
from ididi import Graph, Ignore | ||
|
||
from ..test_data import Config, UserService | ||
|
||
# class User: | ||
# def __init__(self, name: str, role: str): | ||
# self.name = name | ||
# self.role = role | ||
|
||
class User: | ||
def __init__(self, name: str, role: str): | ||
self.name = name | ||
self.role = role | ||
|
||
# def get_user() -> Ignore[User]: | ||
# return User("user", "admin") | ||
|
||
def get_user(config: Config) -> Ignore[User]: | ||
assert isinstance(config, Config) | ||
return User("user", "admin") | ||
|
||
# def validate_admin(user: Annotated[User, get_user]): | ||
# assert user.role == "admin" | ||
# return "ok" | ||
|
||
def validate_admin( | ||
user: Annotated[User, get_user], service: UserService | ||
) -> Ignore[str]: | ||
assert user.role == "admin" | ||
assert isinstance(service, UserService) | ||
return "ok" | ||
|
||
# def test_dg_resolve_params(): | ||
# dg = Graph() | ||
# assert dg.resolve(get_user) | ||
|
||
async def test_resolve_function(): | ||
dg = Graph() | ||
|
||
user = dg.resolve(get_user) | ||
assert isinstance(user, User) | ||
|
||
|
||
def test_dg_resolve_params(): | ||
dg = Graph() | ||
|
||
assert dg.resolve(validate_admin) == "ok" |
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