mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-08-07 17:23:05 +02:00
Shorten client name
This commit is contained in:
+1
-1
@@ -199,7 +199,7 @@ On connect and every 5 minutes thereafter, the community publisher sends a retai
|
|||||||
"model": "T-Deck",
|
"model": "T-Deck",
|
||||||
"firmware_version": "v2.2.2 (Build: 2025-01-15)",
|
"firmware_version": "v2.2.2 (Build: 2025-01-15)",
|
||||||
"radio": "915.0,250.0,10,8",
|
"radio": "915.0,250.0,10,8",
|
||||||
"client_version": "RemoteTerm/2.4.0",
|
"client_version": "RemoteTerm 2.4.0",
|
||||||
"stats": {
|
"stats": {
|
||||||
"battery_mv": 4200,
|
"battery_mv": 4200,
|
||||||
"uptime_secs": 3600,
|
"uptime_secs": 3600,
|
||||||
|
|||||||
@@ -286,12 +286,12 @@ def _build_radio_info() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def _get_client_version() -> str:
|
def _get_client_version() -> str:
|
||||||
"""Return a client version string like 'RemoteTerm/2.4.0'."""
|
"""Return a client version string like ``'RemoteTerm 2.4.0'``."""
|
||||||
try:
|
try:
|
||||||
version = importlib.metadata.version("remoteterm-meshcore")
|
version = importlib.metadata.version("remoteterm-meshcore")
|
||||||
return f"RemoteTerm/{version}"
|
return f"RemoteTerm {version}"
|
||||||
except Exception:
|
except Exception:
|
||||||
return "RemoteTerm/unknown"
|
return "RemoteTerm unknown"
|
||||||
|
|
||||||
|
|
||||||
class CommunityMqttPublisher(BaseMqttPublisher):
|
class CommunityMqttPublisher(BaseMqttPublisher):
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ class TestLwtAndStatusPublish:
|
|||||||
pub, "_fetch_stats", new_callable=AsyncMock, return_value={"battery_mv": 4200}
|
pub, "_fetch_stats", new_callable=AsyncMock, return_value={"battery_mv": 4200}
|
||||||
),
|
),
|
||||||
patch("app.community_mqtt._build_radio_info", return_value="915.0,250.0,10,8"),
|
patch("app.community_mqtt._build_radio_info", return_value="915.0,250.0,10,8"),
|
||||||
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm/2.4.0"),
|
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm 2.4.0"),
|
||||||
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
||||||
):
|
):
|
||||||
await pub._on_connected_async(settings)
|
await pub._on_connected_async(settings)
|
||||||
@@ -533,7 +533,7 @@ class TestLwtAndStatusPublish:
|
|||||||
assert payload["model"] == "T-Deck"
|
assert payload["model"] == "T-Deck"
|
||||||
assert payload["firmware_version"] == "v2.2.2 (Build: 2025-01-15)"
|
assert payload["firmware_version"] == "v2.2.2 (Build: 2025-01-15)"
|
||||||
assert payload["radio"] == "915.0,250.0,10,8"
|
assert payload["radio"] == "915.0,250.0,10,8"
|
||||||
assert payload["client_version"] == "RemoteTerm/2.4.0"
|
assert payload["client_version"] == "RemoteTerm 2.4.0"
|
||||||
assert payload["stats"] == {"battery_mv": 4200}
|
assert payload["stats"] == {"battery_mv": 4200}
|
||||||
|
|
||||||
def test_lwt_and_online_share_same_topic(self):
|
def test_lwt_and_online_share_same_topic(self):
|
||||||
@@ -595,7 +595,7 @@ class TestLwtAndStatusPublish:
|
|||||||
),
|
),
|
||||||
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=None),
|
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=None),
|
||||||
patch("app.community_mqtt._build_radio_info", return_value="0,0,0,0"),
|
patch("app.community_mqtt._build_radio_info", return_value="0,0,0,0"),
|
||||||
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm/unknown"),
|
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm unknown"),
|
||||||
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
||||||
):
|
):
|
||||||
await pub._on_connected_async(settings)
|
await pub._on_connected_async(settings)
|
||||||
@@ -872,23 +872,23 @@ class TestBuildRadioInfo:
|
|||||||
|
|
||||||
class TestGetClientVersion:
|
class TestGetClientVersion:
|
||||||
def test_returns_remoteterm_prefix(self):
|
def test_returns_remoteterm_prefix(self):
|
||||||
"""Should return 'RemoteTerm/...' string."""
|
"""Should return 'RemoteTerm ...' string."""
|
||||||
result = _get_client_version()
|
result = _get_client_version()
|
||||||
assert result.startswith("RemoteTerm/")
|
assert result.startswith("RemoteTerm ")
|
||||||
|
|
||||||
def test_returns_version_from_metadata(self):
|
def test_returns_version_from_metadata(self):
|
||||||
"""Should use importlib.metadata to get version."""
|
"""Should use importlib.metadata to get version."""
|
||||||
with patch("app.community_mqtt.importlib.metadata.version", return_value="1.2.3"):
|
with patch("app.community_mqtt.importlib.metadata.version", return_value="1.2.3"):
|
||||||
result = _get_client_version()
|
result = _get_client_version()
|
||||||
assert result == "RemoteTerm/1.2.3"
|
assert result == "RemoteTerm 1.2.3"
|
||||||
|
|
||||||
def test_fallback_on_error(self):
|
def test_fallback_on_error(self):
|
||||||
"""Should return 'RemoteTerm/unknown' if metadata lookup fails."""
|
"""Should return 'RemoteTerm unknown' if metadata lookup fails."""
|
||||||
with patch(
|
with patch(
|
||||||
"app.community_mqtt.importlib.metadata.version", side_effect=Exception("not found")
|
"app.community_mqtt.importlib.metadata.version", side_effect=Exception("not found")
|
||||||
):
|
):
|
||||||
result = _get_client_version()
|
result = _get_client_version()
|
||||||
assert result == "RemoteTerm/unknown"
|
assert result == "RemoteTerm unknown"
|
||||||
|
|
||||||
|
|
||||||
class TestPublishStatus:
|
class TestPublishStatus:
|
||||||
@@ -917,7 +917,7 @@ class TestPublishStatus:
|
|||||||
),
|
),
|
||||||
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=stats),
|
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=stats),
|
||||||
patch("app.community_mqtt._build_radio_info", return_value="915.0,250.0,10,8"),
|
patch("app.community_mqtt._build_radio_info", return_value="915.0,250.0,10,8"),
|
||||||
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm/2.4.0"),
|
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm 2.4.0"),
|
||||||
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
||||||
):
|
):
|
||||||
await pub._publish_status(settings)
|
await pub._publish_status(settings)
|
||||||
@@ -930,7 +930,7 @@ class TestPublishStatus:
|
|||||||
assert payload["model"] == "T-Deck"
|
assert payload["model"] == "T-Deck"
|
||||||
assert payload["firmware_version"] == "v2.2.2 (Build: 2025-01-15)"
|
assert payload["firmware_version"] == "v2.2.2 (Build: 2025-01-15)"
|
||||||
assert payload["radio"] == "915.0,250.0,10,8"
|
assert payload["radio"] == "915.0,250.0,10,8"
|
||||||
assert payload["client_version"] == "RemoteTerm/2.4.0"
|
assert payload["client_version"] == "RemoteTerm 2.4.0"
|
||||||
assert payload["stats"] == stats
|
assert payload["stats"] == stats
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@@ -954,7 +954,7 @@ class TestPublishStatus:
|
|||||||
),
|
),
|
||||||
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=None),
|
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=None),
|
||||||
patch("app.community_mqtt._build_radio_info", return_value="0,0,0,0"),
|
patch("app.community_mqtt._build_radio_info", return_value="0,0,0,0"),
|
||||||
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm/unknown"),
|
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm unknown"),
|
||||||
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
patch.object(pub, "publish", new_callable=AsyncMock) as mock_publish,
|
||||||
):
|
):
|
||||||
await pub._publish_status(settings)
|
await pub._publish_status(settings)
|
||||||
@@ -985,7 +985,7 @@ class TestPublishStatus:
|
|||||||
),
|
),
|
||||||
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=None),
|
patch.object(pub, "_fetch_stats", new_callable=AsyncMock, return_value=None),
|
||||||
patch("app.community_mqtt._build_radio_info", return_value="0,0,0,0"),
|
patch("app.community_mqtt._build_radio_info", return_value="0,0,0,0"),
|
||||||
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm/unknown"),
|
patch("app.community_mqtt._get_client_version", return_value="RemoteTerm unknown"),
|
||||||
patch.object(pub, "publish", new_callable=AsyncMock),
|
patch.object(pub, "publish", new_callable=AsyncMock),
|
||||||
):
|
):
|
||||||
await pub._publish_status(settings)
|
await pub._publish_status(settings)
|
||||||
|
|||||||
Reference in New Issue
Block a user