This commit is contained in:
Roland Thomas Jr 2025-05-06 23:05:20 -04:00
parent 5d96d6d3d9
commit 05a7f982f2
Signed by: roland
GPG Key ID: 7C3C2B085A4C2872
3 changed files with 47 additions and 2 deletions

View File

@ -1 +1 @@
__version__ = "0.1.15"
__version__ = "0.1.16"

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "falyx"
version = "0.1.15"
version = "0.1.16"
description = "Reliable and introspectable async CLI action framework."
authors = ["Roland Thomas Jr <roland@rtj.dev>"]
license = "MIT"

45
tests/test_run_key.py Normal file
View File

@ -0,0 +1,45 @@
import pytest
from falyx import Action, Falyx
@pytest.mark.asyncio
async def test_run_key():
"""Test if Falyx can run in run key mode."""
falyx = Falyx("Run Key Test")
# Add a simple command
falyx.add_command(
key="T",
description="Test Command",
action=lambda: "Hello, World!",
)
# Run the CLI
result = await falyx.run_key("T")
assert result == "Hello, World!"
@pytest.mark.asyncio
async def test_run_key_recover():
"""Test if Falyx can recover from a failure in run key mode."""
falyx = Falyx("Run Key Recovery Test")
state = {"count": 0}
async def flaky():
if not state["count"]:
state["count"] += 1
raise RuntimeError("Random failure!")
return "ok"
# Add a command that raises an exception
falyx.add_command(
key="E",
description="Error Command",
action=Action("flaky", flaky),
retry=True,
)
result = await falyx.run_key("E")
assert result == "ok"