forked from cleveragents/cleveragents-core
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
"""Step definitions for the CleverAgents CLI feature."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import contextlib
|
|
import io
|
|
from typing import Any, Sequence
|
|
|
|
from behave import then, when
|
|
|
|
from cleveragents.cli import main
|
|
|
|
|
|
def _run_cli(context: Any, args: Sequence[str]) -> None:
|
|
buffer = io.StringIO()
|
|
with contextlib.redirect_stdout(buffer):
|
|
exit_code = main(list(args))
|
|
context.result = {
|
|
"exit_code": exit_code,
|
|
"output": buffer.getvalue(),
|
|
}
|
|
|
|
|
|
@when('I run the CleverAgents CLI with "--help"')
|
|
def step_run_help(context: Any) -> None:
|
|
_run_cli(context, ["--help"])
|
|
|
|
|
|
@then('the output should contain "CleverAgents"')
|
|
def step_output_help(context: Any) -> None:
|
|
assert context.result["exit_code"] == 0
|
|
assert "CleverAgents" in context.result["output"]
|
|
|
|
|
|
@when('I run the CleverAgents CLI with "--version"')
|
|
def step_run_version(context: Any) -> None:
|
|
_run_cli(context, ["--version"])
|
|
|
|
|
|
@then('the output should contain "1.0.0"')
|
|
def step_output_version(context: Any) -> None:
|
|
assert context.result["exit_code"] == 0
|
|
assert "1.0.0" in context.result["output"]
|