mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
chore: linting
This commit is contained in:
parent
4dda02c06c
commit
94e834134f
80 changed files with 443 additions and 404 deletions
|
|
@ -72,7 +72,11 @@ def test_extract_returns_none_when_no_assistant_text_is_present() -> None:
|
|||
anything?" rather than guess whether ``""`` means silence or empty
|
||||
output. Empty-string contents are normalized to ``None`` too."""
|
||||
no_ai = {"messages": [HumanMessage(content="just a question")]}
|
||||
only_tools = {"messages": [AIMessage(content=[{"type": "tool_use", "name": "x", "input": {}}])]}
|
||||
only_tools = {
|
||||
"messages": [
|
||||
AIMessage(content=[{"type": "tool_use", "name": "x", "input": {}}])
|
||||
]
|
||||
}
|
||||
empty_string = {"messages": [AIMessage(content=" ")]}
|
||||
|
||||
assert extract_final_assistant_message(no_ai) is None
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@ async def test_with_retries_returns_result_and_attempts_one_on_first_success() -
|
|||
assert calls == 1
|
||||
|
||||
|
||||
async def test_with_retries_returns_attempt_count_when_succeeding_after_failures() -> None:
|
||||
async def test_with_retries_returns_attempt_count_when_succeeding_after_failures() -> (
|
||||
None
|
||||
):
|
||||
"""A coroutine that fails twice then succeeds returns ``attempts=3``
|
||||
(the actual attempt that produced the result). Locks the contract
|
||||
that the caller can distinguish first-try success from a recovery."""
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ from app.automations.schemas.definition.plan_step import PlanStep
|
|||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
||||
def test_automation_definition_accepts_minimal_valid_input_with_sensible_defaults() -> None:
|
||||
def test_automation_definition_accepts_minimal_valid_input_with_sensible_defaults() -> (
|
||||
None
|
||||
):
|
||||
"""A definition with just ``name`` + a one-step ``plan`` is valid and
|
||||
fills in the rest with safe defaults so users don't have to write
|
||||
out every section to get started."""
|
||||
|
|
|
|||
|
|
@ -32,7 +32,9 @@ def test_environment_finalizes_datetime_output_to_iso_string() -> None:
|
|||
when emitting ``inputs.fired_at`` and other datetime values."""
|
||||
dt = datetime(2026, 5, 28, 14, 30, tzinfo=UTC)
|
||||
|
||||
assert render_template("{{ moment }}", {"moment": dt}) == "2026-05-28T14:30:00+00:00"
|
||||
assert (
|
||||
render_template("{{ moment }}", {"moment": dt}) == "2026-05-28T14:30:00+00:00"
|
||||
)
|
||||
|
||||
|
||||
def test_environment_finalizes_none_output_to_empty_string() -> None:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ def test_action_definition_params_schema_reflects_params_model() -> None:
|
|||
name="N",
|
||||
description="D",
|
||||
params_model=_Topic,
|
||||
build_handler=lambda _ctx: (lambda _p: {}), # type: ignore[arg-type,return-value]
|
||||
build_handler=lambda _ctx: lambda _p: {}, # type: ignore[arg-type,return-value]
|
||||
)
|
||||
|
||||
schema = definition.params_schema
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ class _Params(BaseModel):
|
|||
|
||||
|
||||
def _trigger(type_: str = "test_trigger") -> TriggerDefinition:
|
||||
return TriggerDefinition(type=type_, description="Test trigger.", params_model=_Params)
|
||||
return TriggerDefinition(
|
||||
type=type_, description="Test trigger.", params_model=_Params
|
||||
)
|
||||
|
||||
|
||||
def _action(type_: str = "test_action") -> ActionDefinition:
|
||||
|
|
@ -38,7 +40,7 @@ def _action(type_: str = "test_action") -> ActionDefinition:
|
|||
name="Test",
|
||||
description="Test action.",
|
||||
params_model=_Params,
|
||||
build_handler=lambda _ctx: (lambda _p: {}), # type: ignore[arg-type,return-value]
|
||||
build_handler=lambda _ctx: lambda _p: {}, # type: ignore[arg-type,return-value]
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -112,4 +114,4 @@ def test_all_triggers_returns_defensive_snapshot(
|
|||
snapshot = all_triggers()
|
||||
snapshot.pop("snapshot_test")
|
||||
|
||||
assert get_trigger("snapshot_test") is not None
|
||||
assert get_trigger("snapshot_test") is not None
|
||||
|
|
|
|||
|
|
@ -45,8 +45,12 @@ def test_compute_next_fire_at_respects_dst_offset_change() -> None:
|
|||
winter_after = datetime(2026, 2, 15, 0, 0, tzinfo=UTC)
|
||||
summer_after = datetime(2026, 4, 15, 0, 0, tzinfo=UTC)
|
||||
|
||||
winter_fire = compute_next_fire_at("0 9 * * *", "America/New_York", after=winter_after)
|
||||
summer_fire = compute_next_fire_at("0 9 * * *", "America/New_York", after=summer_after)
|
||||
winter_fire = compute_next_fire_at(
|
||||
"0 9 * * *", "America/New_York", after=winter_after
|
||||
)
|
||||
summer_fire = compute_next_fire_at(
|
||||
"0 9 * * *", "America/New_York", after=summer_after
|
||||
)
|
||||
|
||||
assert winter_fire == datetime(2026, 2, 15, 14, 0, tzinfo=UTC)
|
||||
assert summer_fire == datetime(2026, 4, 15, 13, 0, tzinfo=UTC)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import pytest
|
|||
|
||||
from app.agents.new_chat.context import SurfSenseContextSchema
|
||||
from app.services.new_streaming_service import VercelStreamingService
|
||||
|
||||
from app.tasks.chat.stream_new_chat import (
|
||||
stream_new_chat as old_stream_new_chat,
|
||||
stream_resume_chat as old_stream_resume_chat,
|
||||
|
|
@ -152,7 +151,13 @@ class _FakeSurfsenseDoc:
|
|||
"user_query, image_urls, docs, expected_title, expected_action",
|
||||
[
|
||||
("hello world", None, [], "Understanding your request", "Processing"),
|
||||
("", ["data:image/png;base64,AAA"], [], "Understanding your request", "Processing"),
|
||||
(
|
||||
"",
|
||||
["data:image/png;base64,AAA"],
|
||||
[],
|
||||
"Understanding your request",
|
||||
"Processing",
|
||||
),
|
||||
("", None, [], "Understanding your request", "Processing"),
|
||||
(
|
||||
"doc question",
|
||||
|
|
@ -209,9 +214,10 @@ def test_initial_thinking_step_collapses_many_doc_names() -> None:
|
|||
|
||||
|
||||
def test_image_capability_passes_without_images() -> None:
|
||||
assert check_image_input_capability(
|
||||
user_image_data_urls=None, agent_config=None
|
||||
) is None
|
||||
assert (
|
||||
check_image_input_capability(user_image_data_urls=None, agent_config=None)
|
||||
is None
|
||||
)
|
||||
|
||||
|
||||
def test_image_capability_passes_when_capability_unknown() -> None:
|
||||
|
|
@ -500,9 +506,7 @@ def test_can_recover_provider_rate_limit_rejects_non_rate_limit_exception() -> N
|
|||
def test_spawn_set_ai_responding_bg_noop_without_user_id() -> None:
|
||||
async def _run() -> set[asyncio.Task]:
|
||||
background: set[asyncio.Task] = set()
|
||||
spawn_set_ai_responding_bg(
|
||||
chat_id=1, user_id=None, background_tasks=background
|
||||
)
|
||||
spawn_set_ai_responding_bg(chat_id=1, user_id=None, background_tasks=background)
|
||||
return background
|
||||
|
||||
bg = asyncio.run(_run())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue