mirror of
https://github.com/aaif-goose/goose.git
synced 2026-06-02 06:14:27 +02:00
Apply ruff and add to CI (#40)
This commit is contained in:
@@ -17,6 +17,11 @@ jobs:
|
||||
- name: Source Cargo Environment
|
||||
run: source $HOME/.cargo/env
|
||||
|
||||
- name: Ruff
|
||||
run: |
|
||||
uvx ruff check
|
||||
uvx ruff format --check
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
uv run pytest tests -m 'not integration'
|
||||
@@ -1,4 +1,3 @@
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Dict, Optional
|
||||
@@ -12,10 +11,12 @@ from goose.cli.session import Session
|
||||
from goose.utils import load_plugins
|
||||
from goose.utils.session_file import list_sorted_session_files
|
||||
|
||||
|
||||
@click.group()
|
||||
def goose_cli() -> None:
|
||||
pass
|
||||
|
||||
|
||||
@goose_cli.command()
|
||||
def version() -> None:
|
||||
"""Lists the version of goose and any plugins"""
|
||||
@@ -100,14 +101,17 @@ def session_clear(keep: int) -> None:
|
||||
def get_session_files() -> Dict[str, Path]:
|
||||
return list_sorted_session_files(SESSIONS_PATH)
|
||||
|
||||
|
||||
@click.group(
|
||||
invoke_without_command=True,
|
||||
name="goose",
|
||||
help="AI-powered tool to assist in solving programming and operational tasks",)
|
||||
help="AI-powered tool to assist in solving programming and operational tasks",
|
||||
)
|
||||
@click.pass_context
|
||||
def cli(_: click.Context, **kwargs: Dict) -> None:
|
||||
pass
|
||||
|
||||
|
||||
all_cli_group_options = load_plugins("goose.cli.group_option")
|
||||
for option in all_cli_group_options.values():
|
||||
cli = option()(cli)
|
||||
|
||||
@@ -85,36 +85,41 @@ def test_session_clear_command(mock_session_files_path, create_session_file):
|
||||
def test_combined_group_option():
|
||||
with patch("goose.utils.load_plugins") as mock_load_plugin:
|
||||
group_option_name = "--describe-commands"
|
||||
|
||||
def option_callback(ctx, *_):
|
||||
click.echo("Option callback")
|
||||
ctx.exit()
|
||||
|
||||
mock_group_options = {
|
||||
'option1': lambda: click.option(
|
||||
"option1": lambda: click.option(
|
||||
group_option_name,
|
||||
is_flag=True,
|
||||
callback=option_callback,
|
||||
),
|
||||
}
|
||||
|
||||
def side_effect_func(param):
|
||||
if param == "goose.cli.group_option":
|
||||
return mock_group_options
|
||||
elif param == "goose.cli.group":
|
||||
return { }
|
||||
return {}
|
||||
|
||||
mock_load_plugin.side_effect = side_effect_func
|
||||
|
||||
# reload cli after mocking
|
||||
importlib.reload(importlib.import_module('goose.cli.main'))
|
||||
importlib.reload(importlib.import_module("goose.cli.main"))
|
||||
import goose.cli.main
|
||||
|
||||
cli = goose.cli.main.cli
|
||||
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, [group_option_name])
|
||||
assert result.exit_code == 0
|
||||
|
||||
|
||||
def test_combined_group_commands(mock_session):
|
||||
mock_session_class, mock_session_instance = mock_session
|
||||
runner = CliRunner()
|
||||
runner.invoke(cli, ["session", "resume", "session1", "--profile", "default"])
|
||||
mock_session_class.assert_called_once_with(name="session1", profile="default")
|
||||
mock_session_instance.run.assert_called_once()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user