Fix typing and minor issues
This commit is contained in:
parent
2db2253578
commit
72ab627a34
54 changed files with 635 additions and 589 deletions
|
|
@ -1,71 +0,0 @@
|
|||
from functools import lru_cache
|
||||
|
||||
import pytest
|
||||
|
||||
from great_ai import (
|
||||
ArgumentValidationError,
|
||||
GreatAI,
|
||||
WrongDecoratorOrderError,
|
||||
parameter,
|
||||
)
|
||||
|
||||
|
||||
def test_create_trivial_cases() -> None:
|
||||
@GreatAI.create
|
||||
def hello_world_1(name: str) -> str:
|
||||
return f"Hello {name}!"
|
||||
|
||||
assert hello_world_1("andras").output == "Hello andras!"
|
||||
|
||||
@GreatAI.create
|
||||
def hello_world_2(name):
|
||||
return f"Hello {name}!"
|
||||
|
||||
assert hello_world_2("andras").output == "Hello andras!"
|
||||
|
||||
@GreatAI.create()
|
||||
def hello_world_3(name: str) -> str:
|
||||
return f"Hello {name}!"
|
||||
|
||||
assert hello_world_3("andras").output == "Hello andras!"
|
||||
|
||||
@GreatAI.create()
|
||||
def hello_world_4(name):
|
||||
return f"Hello {name}!"
|
||||
|
||||
assert hello_world_4("andras").output == "Hello andras!"
|
||||
|
||||
|
||||
def test_create_with_other_decorator() -> None:
|
||||
@GreatAI.create
|
||||
@lru_cache
|
||||
def hello_world(name: str) -> str:
|
||||
return f"Hello {name}!"
|
||||
|
||||
assert hello_world("andras").output == "Hello andras!"
|
||||
|
||||
@lru_cache
|
||||
@GreatAI.create()
|
||||
def hello_world(name: str) -> str:
|
||||
return f"Hello {name}!"
|
||||
|
||||
assert hello_world("andras").output == "Hello andras!"
|
||||
|
||||
|
||||
def test_with_parameter() -> None:
|
||||
@GreatAI.create
|
||||
@parameter("name", validator=lambda v: len(v) > 5)
|
||||
def hello_world(name: str) -> str:
|
||||
return f"Hello {name}!"
|
||||
|
||||
assert hello_world("andras").output == "Hello andras!"
|
||||
|
||||
with pytest.raises(ArgumentValidationError):
|
||||
hello_world("short")
|
||||
|
||||
with pytest.raises(WrongDecoratorOrderError):
|
||||
|
||||
@parameter("name", validator=lambda v: len(v) > 5)
|
||||
@GreatAI.create
|
||||
def hello_world(name: str) -> str:
|
||||
return f"Hello {name}!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue