diff --git a/tests/great_ai/__init__.py b/tests/great_ai/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/great_ai/test_basic_starters.py b/tests/great_ai/test_basic_starters.py new file mode 100644 index 0000000..c5c77b2 --- /dev/null +++ b/tests/great_ai/test_basic_starters.py @@ -0,0 +1,59 @@ +import unittest +from functools import lru_cache + +import pytest + +from src.great_ai import ( + ArgumentValidationError, + GreatAI, + WrongDecoratorOrderError, + parameter, +) + + +class TestHumanReadableToByte(unittest.TestCase): + def test_create_simple_cases(self) -> None: + @GreatAI.create + def hello_world(name: str) -> str: + return f"Hello {name}!" + + assert hello_world("andras").output == "Hello andras!" + + @GreatAI.create() + def hello_world(name: str) -> str: + return f"Hello {name}!" + + assert hello_world("andras").output == "Hello andras!" + + def test_create_with_other_decorator(self) -> 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(self) -> 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}!" diff --git a/tests/large_file/test_human_readable_to_byte.py b/tests/large_file/test_human_readable_to_byte.py index 271722e..cc0e995 100644 --- a/tests/large_file/test_human_readable_to_byte.py +++ b/tests/large_file/test_human_readable_to_byte.py @@ -12,7 +12,7 @@ class TestHumanReadableToByte(unittest.TestCase): assert human_readable_to_byte("0.5KB") == 512 assert human_readable_to_byte("20.5KB") == 1024 * 20 + 512 - def test_formating(self) -> None: + def test_formatting(self) -> None: assert human_readable_to_byte(" 1MB") == 1024 * 1024 assert human_readable_to_byte(" 2 MB") == 1024 * 1024 * 2 assert human_readable_to_byte(" 4 MB ") == 1024 * 1024 * 4