Introduce complete test coverage for the ARTEMIS platform across multiple layers: Unit tests: Add tests for agent nodes (Planner, Operator, Validator, Diagnoser, FlashRunner, Explorer), tools, utils (OCR/XML fusion, UI hierarchy), and data engine. Integration tests: Add live tool verification, reactive runner, IME, and standalone workflow tests. E2E tests: Add end-to-end scenario tests for media playback and failure recovery flows. Fixtures & mocks: Add mock inputs (audio, video, screenshot) and test utilities.
56 lines
2.1 KiB
Python
56 lines
2.1 KiB
Python
# Copyright 2026 Google LLC
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
"""Unit tests for Telemetry & Span Lifecycle Tracing."""
|
|
|
|
import pytest
|
|
from pathlib import Path
|
|
from artemis.telemetry.models import SpanType
|
|
from artemis.telemetry.tracer import TelemetryTracer
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_telemetry_span_lifecycle(tmp_path: Path):
|
|
"""Verify TelemetryTracer properly records and persists nested spans."""
|
|
tracer = TelemetryTracer(trace_id="test-session-001", traces_dir=tmp_path)
|
|
|
|
async with tracer.start_span("parent_agent_step", span_type=SpanType.AGENT) as parent_span:
|
|
assert parent_span.status == "running"
|
|
assert parent_span.name == "parent_agent_step"
|
|
|
|
async with tracer.start_span(
|
|
"child_device_action", span_type=SpanType.DEVICE_ACTION, payload={"action": "click"}
|
|
) as child_span:
|
|
assert child_span.parent_id == parent_span.span_id
|
|
assert child_span.payload["action"] == "click"
|
|
|
|
# Spans should be persisted in JSONL
|
|
assert len(tracer.spans) == 2
|
|
child_recorded = tracer.spans[0]
|
|
parent_recorded = tracer.spans[1]
|
|
|
|
assert child_recorded.name == "child_device_action"
|
|
assert child_recorded.status == "success"
|
|
assert child_recorded.duration_ms is not None
|
|
|
|
assert parent_recorded.name == "parent_agent_step"
|
|
assert parent_recorded.status == "success"
|
|
|
|
# File existence
|
|
log_file = tmp_path / "telemetry_spans.jsonl"
|
|
assert log_file.exists()
|
|
content = log_file.read_text(encoding="utf-8")
|
|
assert "child_device_action" in content
|
|
assert "parent_agent_step" in content
|