21 lines
735 B
Python
21 lines
735 B
Python
import tempfile
|
|
import os
|
|
from idea78_solarsphere_offline_first.csv_adapter import CSVAdapter
|
|
from idea78_solarsphere_offline_first.core import TelemetryPoint
|
|
|
|
|
|
def test_csv_adapter_loads_telemetry_points():
|
|
with tempfile.NamedTemporaryFile(mode="w+", delete=False, suffix=".csv") as tf:
|
|
tf.write("site_id,ts,lat,lon,metric,value,quality\n")
|
|
tf.write("siteA,1000,1.0,2.0,temperature,25.0,good\n")
|
|
tf.flush()
|
|
path = tf.name
|
|
|
|
adapter = CSVAdapter(path)
|
|
pts = adapter.load_telemetry()
|
|
assert isinstance(pts, list) and len(pts) == 1
|
|
p = pts[0]
|
|
assert isinstance(p, TelemetryPoint)
|
|
assert p.site_id == "siteA" and p.metric == "temperature" and p.value == 25.0
|
|
os.unlink(path)
|