Added Commands Management

This commit is contained in:
2025-10-24 23:02:44 +02:00
parent a4e122f4ea
commit 06aff27cad
26 changed files with 88445 additions and 2 deletions

25
tests/test_commands.py Normal file
View File

@@ -0,0 +1,25 @@
import pytest
from myfasthtml.core.commands import Command, CommandsManager
def callback():
return "Hello World"
@pytest.fixture(autouse=True)
def test_reset_command_manager():
CommandsManager.reset()
def test_i_can_create_a_command_with_no_params():
command = Command('test', 'Command description', callback)
assert command.id is not None
assert command.name == 'test'
assert command.description == 'Command description'
assert command.execute() == "Hello World"
def test_command_are_registered():
command = Command('test', 'Command description', callback)
assert CommandsManager.commands.get(str(command.id)) is command