Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions airbyte/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any
import datetime # noqa: TC003 # Pydantic resolves this annotation at runtime.
from typing import Any

from pydantic import BaseModel, Field


if TYPE_CHECKING:
import datetime
MAX_SINGLE_LINE_LENGTH = 60
AIRBYTE_DOCUMENT_RENDERING = "airbyte_document_rendering"
TITLE_PROPERTY = "title_property"
CONTENT_PROPS = "content_properties"
METADATA_PROPERTIES = "metadata_properties"


class Document(BaseModel):
Expand Down
10 changes: 7 additions & 3 deletions airbyte/mcp/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,11 @@ def run_cloud_sync(
@mcp_tool()
def deploy_noop_destination_to_cloud(
ctx: Context,
name: Annotated[str, TraceArg.FINGERPRINT] = "No-op Destination",
destination_name: Annotated[
str,
Field(description="The name to use when deploying the No-op destination."),
TraceArg.FINGERPRINT,
] = "No-op Destination",
*,
workspace_id: Annotated[
str | None,
Expand All @@ -1051,13 +1055,13 @@ def deploy_noop_destination_to_cloud(
),
TraceArg.OMIT,
],
unique: bool = True,
unique: Annotated[bool, Field(description="Whether to require a unique name.")] = True,
) -> str:
"""Deploy the No-op destination to Airbyte Cloud for testing purposes."""
destination = get_noop_destination()
workspace: CloudWorkspace = _get_cloud_workspace(ctx, workspace_id)
deployed_destination = workspace.deploy_destination(
name=name,
name=destination_name,
destination=destination,
unique=unique,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/fixtures/arg_trace_plan.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"workspace_id": "omit"
},
"deploy_noop_destination_to_cloud": {
"name": "fingerprint",
"destination_name": "fingerprint",
"unique": "value allowed=[false,true]",
"workspace_id": "omit"
},
Expand Down
49 changes: 49 additions & 0 deletions tests/unit_tests/test_documents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2026 Airbyte, Inc., all rights reserved.
"""Regression coverage for document model construction and rendering."""

from __future__ import annotations

from datetime import datetime as DateTime
from typing import Any

import pytest

from airbyte._util.document_rendering import DocumentRenderer
from airbyte.documents import Document


@pytest.mark.parametrize(
"fields",
[
{},
{"last_modified": None},
{"last_modified": "2026-10-20T12:00:00Z"},
],
)
def test_document_construction(fields: dict[str, Any]) -> None:
"""Documents validate without callers rebuilding the model's forward references."""
document = Document(content="Example", metadata={"source": "test"}, **fields)
assert document.page_content == "Example"
assert document.metadata == {"source": "test"}
if fields.get("last_modified"):
assert document.last_modified == DateTime.fromisoformat(
"2026-10-20T12:00:00+00:00"
)
else:
assert document.last_modified is None


def test_document_rendering() -> None:
"""The record-to-document path constructs the document model successfully."""
renderer = DocumentRenderer(content_properties=["body"], metadata_properties=["id"])
document = renderer.render_document({"body": "Example", "id": "record-1"})
assert document.page_content == "Example"
assert document.metadata == {"id": "record-1"}


def test_document_schema() -> None:
"""The model's JSON schema resolves the optional timestamp at runtime."""
schema = Document.model_json_schema()
assert {"type": "string", "format": "date-time"} in schema["properties"][
"last_modified"
]["anyOf"]
55 changes: 55 additions & 0 deletions tests/unit_tests/test_mcp_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import asyncio
import functools
import inspect
from dataclasses import dataclass
from datetime import datetime, timezone
from types import SimpleNamespace
Expand Down Expand Up @@ -3802,3 +3803,57 @@ def test_redact_stream_diagnostics() -> None:
"error": leaky,
})
assert "s3cret" not in str(data)


def test_deploy_noop_destination_to_cloud_uses_destination_name(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""Verify the No-op deploy tool accepts `destination_name` and documents its params."""
deployed: dict[str, object] = {}

def fake_deploy_destination(**kwargs: object) -> SimpleNamespace:
deployed.update(kwargs)
return SimpleNamespace(
connector_id="noop-id",
connector_url="https://cloud.airbyte.com/noop-id",
)

workspace = SimpleNamespace(deploy_destination=fake_deploy_destination)
monkeypatch.setattr(
cloud_mcp, "_get_cloud_workspace", lambda ctx, workspace_id=None: workspace
)
monkeypatch.setattr(cloud_mcp, "get_noop_destination", object)
monkeypatch.setattr(cloud_mcp, "register_guid_created_in_session", lambda _: None)

result = cloud_mcp.deploy_noop_destination_to_cloud(
cast(Context, object()),
destination_name="my-noop",
workspace_id=None,
unique=False,
)

assert deployed["name"] == "my-noop"
assert deployed["unique"] is False
assert "noop-id" in result

default_result = cloud_mcp.deploy_noop_destination_to_cloud(
cast(Context, object()), workspace_id=None
)
assert deployed["name"] == "No-op Destination"
assert deployed["unique"] is True
assert "noop-id" in default_result


def test_deploy_noop_destination_to_cloud_params_have_descriptions() -> None:
"""Verify every No-op deploy tool parameter exposes a schema description."""
signature = inspect.signature(cloud_mcp.deploy_noop_destination_to_cloud)
for param_name in ("destination_name", "workspace_id", "unique"):
annotation = signature.parameters[param_name].annotation
field_infos = [
meta
for meta in getattr(annotation, "__metadata__", ())
if hasattr(meta, "description")
]
assert field_infos, param_name
assert field_infos[0].description, param_name
assert "name" not in signature.parameters
Loading