pulsemesh-open-telemetry-vi.../tests/test_telemetry.py

20 lines
608 B
Python

import sys
import os
# Ensure package source is importable during tests
SRC_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "src"))
if SRC_DIR not in sys.path:
sys.path.insert(0, SRC_DIR)
from pulsemesh_open_telemetry_visualization_a.telemetry import TelemetrySample
def test_telemetry_sample_basic():
ts = TelemetrySample(timestamp=1.0, source="tester", metric="test.metric", value=3.14, units="unit")
d = ts.to_dict()
assert isinstance(d, dict)
assert d["metric"] == "test.metric"
assert d["value"] == 3.14
s = ts.to_json()
assert isinstance(s, str)