4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
from __future__ import annotations
|
|
|
|
import httpx
|
|
import pytest
|
|
|
|
from integrations.trello import TrelloConfig, create_trello_card, validate_trello_config
|
|
|
|
|
|
def test_trello_validation_and_card_creation_e2e(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
config = TrelloConfig(
|
|
api_key="trello_key",
|
|
token="trello_token",
|
|
board_id="board123",
|
|
list_id="list123",
|
|
)
|
|
|
|
calls: list[tuple[str, str]] = []
|
|
|
|
def fake_request_json(config, method, path, *, params=None, json=None):
|
|
calls.append((method, path))
|
|
|
|
if method == "GET" and path == "/members/me":
|
|
return {"id": "member123", "username": "test_user"}
|
|
|
|
if method == "POST" and path == "/cards":
|
|
return {
|
|
"id": "card123",
|
|
"name": "Critical incident",
|
|
"desc": "Root cause details",
|
|
"idList": "list123",
|
|
}
|
|
|
|
raise AssertionError(f"Unexpected request: {method} {path}")
|
|
|
|
monkeypatch.setattr("integrations.trello.client._request_json", fake_request_json)
|
|
|
|
validation = validate_trello_config(config)
|
|
assert validation.ok is True
|
|
assert "@test_user" in validation.detail
|
|
|
|
result = create_trello_card(
|
|
config=config,
|
|
name="Critical incident",
|
|
desc="Root cause details",
|
|
)
|
|
|
|
assert result["id"] == "card123"
|
|
assert result["name"] == "Critical incident"
|
|
assert result["idList"] == "list123"
|
|
assert calls == [("GET", "/members/me"), ("POST", "/cards")]
|
|
|
|
|
|
def test_trello_validation_failure_e2e(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
config = TrelloConfig(
|
|
api_key="bad_key",
|
|
token="bad_token",
|
|
board_id="board123",
|
|
list_id="list123",
|
|
)
|
|
|
|
request = httpx.Request("GET", "https://api.trello.com/1/members/me")
|
|
response = httpx.Response(401, request=request, text="unauthorized")
|
|
|
|
def fake_request_json(config, method, path, *, params=None, json=None):
|
|
if method == "GET" and path == "/members/me":
|
|
raise httpx.HTTPStatusError(
|
|
"Client error '401 Unauthorized' for url 'https://api.trello.com/1/members/me'",
|
|
request=request,
|
|
response=response,
|
|
)
|
|
raise AssertionError(f"Unexpected request: {method} {path}")
|
|
|
|
monkeypatch.setattr("integrations.trello.client._request_json", fake_request_json)
|
|
|
|
validation = validate_trello_config(config)
|
|
assert validation.ok is False
|
|
assert "401" in validation.detail or "unauthorized" in validation.detail.lower()
|