mirror of
https://github.com/smittix/intercept.git
synced 2026-06-08 14:11:54 -07:00
fix(meshcore): fix test isolation, enum value assertions, and os import
This commit is contained in:
@@ -11,13 +11,10 @@ class TestAvailability:
|
||||
assert isinstance(is_meshcore_available(), bool)
|
||||
|
||||
def test_false_when_not_installed(self):
|
||||
with patch.dict("sys.modules", {"meshcore": None}):
|
||||
import importlib
|
||||
with patch("utils.meshcore.HAS_MESHCORE", False):
|
||||
from utils.meshcore import is_meshcore_available
|
||||
|
||||
import utils.meshcore as m
|
||||
|
||||
importlib.reload(m)
|
||||
assert m.is_meshcore_available() is False
|
||||
assert is_meshcore_available() is False
|
||||
|
||||
|
||||
class TestMeshcoreMessage:
|
||||
@@ -49,6 +46,12 @@ class TestMeshcoreMessage:
|
||||
d = self._make(snr=None).to_dict()
|
||||
assert d["snr"] is None
|
||||
|
||||
def test_to_dict_timestamp_is_iso(self):
|
||||
msg = self._make(timestamp=datetime(2026, 5, 11, 10, 30, 0, tzinfo=timezone.utc))
|
||||
d = msg.to_dict()
|
||||
assert "2026-05-11" in d["timestamp"]
|
||||
assert isinstance(d["timestamp"], str)
|
||||
|
||||
|
||||
class TestMeshcoreNode:
|
||||
def test_to_dict_includes_is_repeater(self):
|
||||
@@ -91,7 +94,7 @@ class TestConnectionState:
|
||||
def test_state_enum_values(self):
|
||||
from utils.meshcore import ConnectionState
|
||||
|
||||
assert ConnectionState.DISCONNECTED
|
||||
assert ConnectionState.CONNECTING
|
||||
assert ConnectionState.CONNECTED
|
||||
assert ConnectionState.ERROR
|
||||
assert ConnectionState.DISCONNECTED.value == "disconnected"
|
||||
assert ConnectionState.CONNECTING.value == "connecting"
|
||||
assert ConnectionState.CONNECTED.value == "connected"
|
||||
assert ConnectionState.ERROR.value == "error"
|
||||
|
||||
+1
-2
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
import contextlib
|
||||
import enum
|
||||
import glob
|
||||
import os
|
||||
import queue
|
||||
import threading
|
||||
from dataclasses import dataclass
|
||||
@@ -231,8 +232,6 @@ def list_serial_ports() -> list[str]:
|
||||
|
||||
def _is_docker() -> bool:
|
||||
"""Return True when running inside a Docker container."""
|
||||
import os
|
||||
|
||||
return os.path.exists("/.dockerenv") or os.environ.get("INTERCEPT_DOCKER") == "1"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user