summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-19 14:39:38 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-19 14:39:38 +0200
commit9e7b75bb0f6f6649fb00f2dc97059e90b7d52875 (patch)
tree94463bba19b424fdce6db0d4dacbc1901af8ea95 /packages/meshbay-node/tests
parent86188385cbdae1ee90c1dca7a7b9db2edef1ecd4 (diff)
downloadmeshbay-9e7b75bb0f6f6649fb00f2dc97059e90b7d52875.tar.gz
style: the 98 ruff could not fix, so the linter is a signal again
The pass before this applied ruff's own fixes. These are the ones needing a decision, and the point of doing them is that `ruff check .` now passes: a linter reporting 98 known-acceptable findings reports nothing, because the next real one arrives invisible. **Lines over 100 (70).** Mostly wrapped where they stood. Two exceptions: the aligned trailing comments in `protocol.py`'s message table were shortened rather than wrapped, because wrapping one row of a table breaks the table; and in `models.py` the column comments moved above their columns for the same reason. **Imports below the first statement (14).** `csam.py` kept its FastAPI imports under a section header halfway down the file; two node tests had a constant and a `pytestmark` wedged between two import blocks. Moved, not suppressed. **Bindings nothing reads (4).** Three in tests, where the call stays and only the name goes — `_user(client, "listener")` is there to create the user, not to return one. The fourth was in `revocation.py` and was not a lint finding at all: `_connect_and_listen` opened an httpx stream to the WebSocket URL, did `pass`, and then opened the real connection through the `websockets` library. One pointless request per connect, left over from before that library was used directly. Removed, and `httpx` with it. **`l` as a name (4)**, **semicolons (6)** in the POC spikes, and the rest. 2893 passed, the same count as the two commits before it. `meshbay_node/revocation.py` is worth a decision separately: 154 lines that nothing imports, superseded by `hub_client.maintain_ws`'s `on_revocation`. This commit only stopped it failing the linter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests')
-rw-r--r--packages/meshbay-node/tests/test_audio_transcode.py6
-rw-r--r--packages/meshbay-node/tests/test_enrich_photo.py3
-rw-r--r--packages/meshbay-node/tests/test_indexer.py3
-rw-r--r--packages/meshbay-node/tests/test_multi_group.py6
-rw-r--r--packages/meshbay-node/tests/test_node_status.py1
-rw-r--r--packages/meshbay-node/tests/test_packaging_win.py5
-rw-r--r--packages/meshbay-node/tests/test_roster_pairing.py3
-rw-r--r--packages/meshbay-node/tests/test_security_regressions.py3
-rw-r--r--packages/meshbay-node/tests/test_transfer_slots_wire.py7
-rw-r--r--packages/meshbay-node/tests/test_webrtc_transport.py19
10 files changed, 31 insertions, 25 deletions
diff --git a/packages/meshbay-node/tests/test_audio_transcode.py b/packages/meshbay-node/tests/test_audio_transcode.py
index a6557f0..acb39b7 100644
--- a/packages/meshbay-node/tests/test_audio_transcode.py
+++ b/packages/meshbay-node/tests/test_audio_transcode.py
@@ -145,7 +145,8 @@ async def test_missing_file_id_is_an_error(tmp_path, media_cache):
sk_node = Ed25519PrivateKey.generate()
session = WebRTCPeerSession.__new__(WebRTCPeerSession)
session._ctx = {
- "roots": one_root(tmp_path), "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek),
+ "roots": one_root(tmp_path),
+ "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek),
"gek": gek, "sk_node": sk_node, "media_cache": media_cache,
}
session._group_id = None
@@ -170,7 +171,8 @@ async def test_multi_chunk_cached_blob_reassembles_correctly(tmp_path, media_cac
sk_node = Ed25519PrivateKey.generate()
session = WebRTCPeerSession.__new__(WebRTCPeerSession)
session._ctx = {
- "roots": one_root(tmp_path), "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek),
+ "roots": one_root(tmp_path),
+ "index": GroupIndex(group_id="g" * 32, sk_node=sk_node, gek=gek),
"gek": gek, "sk_node": sk_node, "media_cache": media_cache,
}
session._group_id = None
diff --git a/packages/meshbay-node/tests/test_enrich_photo.py b/packages/meshbay-node/tests/test_enrich_photo.py
index fb0530c..d1bbd28 100644
--- a/packages/meshbay-node/tests/test_enrich_photo.py
+++ b/packages/meshbay-node/tests/test_enrich_photo.py
@@ -166,7 +166,8 @@ async def test_enricher_corrects_orientation(tmp_path, media_cache):
"width/height must reflect the EXIF-corrected orientation, not the raw stored frame")
thumb_bytes = await media_cache.get_thumb(fields["thumb_hash"])
thumb = Image.open(io.BytesIO(thumb_bytes))
- assert thumb.size[0] < thumb.size[1], "the stored thumbnail itself must be portrait, not sideways"
+ assert thumb.size[0] < thumb.size[1], (
+ "the stored thumbnail itself must be portrait, not sideways")
def test_gps_is_never_read_by_this_module():
diff --git a/packages/meshbay-node/tests/test_indexer.py b/packages/meshbay-node/tests/test_indexer.py
index 48bf399..e97e2ef 100644
--- a/packages/meshbay-node/tests/test_indexer.py
+++ b/packages/meshbay-node/tests/test_indexer.py
@@ -396,7 +396,8 @@ async def test_scan_interrupted_partway_leaves_only_completed_files_cached(
indexer_mod._scan_file = real_scan_file
assert resumed.index.count == 5
- assert len(calls) == 2, f"expected only the 2 not-yet-cached files to be hashed, got {len(calls)}"
+ assert len(calls) == 2, (
+ f"expected only the 2 not-yet-cached files to be hashed, got {len(calls)}")
# ── Progress state ───────────────────────────────────────────────────────────
diff --git a/packages/meshbay-node/tests/test_multi_group.py b/packages/meshbay-node/tests/test_multi_group.py
index e095426..b75bad0 100644
--- a/packages/meshbay-node/tests/test_multi_group.py
+++ b/packages/meshbay-node/tests/test_multi_group.py
@@ -72,10 +72,12 @@ async def multi_group_server(sk_node, sk_hub, gek_a, gek_b, dir_a, dir_b, tmp_pa
hub_pk_pem = sk_hub.public_key().public_bytes(
serialization.Encoding.PEM, serialization.PublicFormat.SubjectPublicKeyInfo)
- indexer_a = DirectoryIndexer(roots=one_root(dir_a), group_id="group-a", sk_node=sk_node, gek=gek_a)
+ indexer_a = DirectoryIndexer(roots=one_root(dir_a), group_id="group-a",
+ sk_node=sk_node, gek=gek_a)
await indexer_a.initial_scan()
- indexer_b = DirectoryIndexer(roots=one_root(dir_b), group_id="group-b", sk_node=sk_node, gek=gek_b)
+ indexer_b = DirectoryIndexer(roots=one_root(dir_b), group_id="group-b",
+ sk_node=sk_node, gek=gek_b)
await indexer_b.initial_scan()
# RootSet, not a bare Path — what the daemon actually puts in a group context.
diff --git a/packages/meshbay-node/tests/test_node_status.py b/packages/meshbay-node/tests/test_node_status.py
index 7a27623..8bb2f39 100644
--- a/packages/meshbay-node/tests/test_node_status.py
+++ b/packages/meshbay-node/tests/test_node_status.py
@@ -207,7 +207,6 @@ async def test_node_status_catches_send_failure(tmp_path, roster):
not silently vanish — it used to, because _send was outside the try block."""
session = await _session(tmp_path, roster, operator=True,
node_user_id="grenet")
- original_send = session._send
sent = []
call_count = [0]
diff --git a/packages/meshbay-node/tests/test_packaging_win.py b/packages/meshbay-node/tests/test_packaging_win.py
index 7b44bbe..aa77c29 100644
--- a/packages/meshbay-node/tests/test_packaging_win.py
+++ b/packages/meshbay-node/tests/test_packaging_win.py
@@ -1230,13 +1230,14 @@ def test_service_mode_ps1_starts_the_task_after_installing_it():
already-running task pointlessly on every mode switch away from service.
"""
src = (WIN / "service-mode.ps1").read_text(encoding="utf-8")
- install_branch, remove_branch = src.split('$Action -eq "install"', 1)[1], None
+ install_branch = src.split('$Action -eq "install"', 1)[1]
assert '"run"' in install_branch or "'run'" in install_branch, (
"service-mode.ps1 registers the task but never starts it -- the "
"daemon stays down until the next reboot")
# The run step must be conditioned on install having actually succeeded,
# not fired unconditionally regardless of $Action.
- guard_line = src[src.index('$Action -eq "install"') - 40:src.index('$Action -eq "install"') + 40]
+ at = src.index('$Action -eq "install"')
+ guard_line = src[at - 40:at + 40]
assert "-and" in guard_line or "-not $failed" in install_branch, (
"the follow-up `run` must be gated on Action=install and success, "
"not run unconditionally on every invocation including remove")
diff --git a/packages/meshbay-node/tests/test_roster_pairing.py b/packages/meshbay-node/tests/test_roster_pairing.py
index 67c3b08..82336e2 100644
--- a/packages/meshbay-node/tests/test_roster_pairing.py
+++ b/packages/meshbay-node/tests/test_roster_pairing.py
@@ -569,7 +569,8 @@ def test_challenge_carries_node_pk_in_source():
builds, whatever the surrounding handshake does.
"""
source = (Path(__file__).parent.parent
- / "src" / "meshbay_node" / "transport" / "webrtc_server.py").read_text(encoding="utf-8")
+ / "src" / "meshbay_node" / "transport"
+ / "webrtc_server.py").read_text(encoding="utf-8")
challenge = source[source.find("MNP.HANDSHAKE_CHALLENGE,"):]
challenge = challenge[:challenge.find("})")]
assert "node_pk" in challenge, (
diff --git a/packages/meshbay-node/tests/test_security_regressions.py b/packages/meshbay-node/tests/test_security_regressions.py
index bfe25b9..7010523 100644
--- a/packages/meshbay-node/tests/test_security_regressions.py
+++ b/packages/meshbay-node/tests/test_security_regressions.py
@@ -462,7 +462,8 @@ def test_no_member_can_hand_the_node_key_material(tmp_path):
)
source = (Path(__file__).parent.parent
- / "src" / "meshbay_node" / "transport" / "webrtc_server.py").read_text(encoding="utf-8")
+ / "src" / "meshbay_node" / "transport"
+ / "webrtc_server.py").read_text(encoding="utf-8")
assert "_do_gek_bundle_store" not in source
assert "_admin_exec_bundle_store" not in source
diff --git a/packages/meshbay-node/tests/test_transfer_slots_wire.py b/packages/meshbay-node/tests/test_transfer_slots_wire.py
index c9fc85a..d96456c 100644
--- a/packages/meshbay-node/tests/test_transfer_slots_wire.py
+++ b/packages/meshbay-node/tests/test_transfer_slots_wire.py
@@ -19,6 +19,9 @@ Three things can only be checked here:
"""
import pytest
+from meshbay_common.protocol import MNP
+from meshbay_node.transfers import DOWNLOAD, UPLOAD
+from meshbay_node.transport.webrtc_server import WebRTCPeerSession
# Every test drives a message handler, and in the node a message handler always
# runs inside the event loop: `_do_transfer_open` starts the sweeper task there.
@@ -26,10 +29,6 @@ import pytest
# on "no current event loop" the moment the sweeper stopped being faked.
pytestmark = pytest.mark.asyncio
-from meshbay_common.protocol import MNP
-from meshbay_node.transfers import DOWNLOAD, UPLOAD
-from meshbay_node.transport.webrtc_server import WebRTCPeerSession
-
class _Session(WebRTCPeerSession):
"""A session with the DataChannel replaced by a list, and nothing else."""
diff --git a/packages/meshbay-node/tests/test_webrtc_transport.py b/packages/meshbay-node/tests/test_webrtc_transport.py
index 4aba99f..91a6e1c 100644
--- a/packages/meshbay-node/tests/test_webrtc_transport.py
+++ b/packages/meshbay-node/tests/test_webrtc_transport.py
@@ -26,6 +26,11 @@ from cryptography.hazmat.primitives.asymmetric.ed25519 import (
Ed25519PublicKey,
)
from meshbay_common import MNP_VERSION
+from meshbay_common.adminop import (
+ OP_FILE_DELETE,
+ OP_INVITE_CREATE,
+ admin_transcript,
+)
from meshbay_common.crypto import (
generate_gek,
pk_to_b64,
@@ -35,16 +40,6 @@ from meshbay_common.crypto import (
wrap_gek_aes,
)
from meshbay_common.groupbox import PURPOSE_ACK, PURPOSE_INDEX, unseal
-from meshbay_common.protocol import MNP
-from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes
-
-TEST_GROUP = "g"
-
-from meshbay_common.adminop import (
- OP_FILE_DELETE,
- OP_INVITE_CREATE,
- admin_transcript,
-)
from meshbay_common.handshake import (
NONCE_LEN,
ROLE_CLIENT,
@@ -55,6 +50,8 @@ from meshbay_common.handshake import (
webrtc_binding,
)
from meshbay_common.join import ROLE_MEMBER, ROLE_OPERATOR, join_transcript
+from meshbay_common.protocol import MNP
+from meshbay_common.webcrypto import chunk_key_aes, decrypt_chunk_aes
from meshbay_node.bundle_store import BundleStore
from meshbay_node.indexer import DirectoryIndexer
from meshbay_node.roster import Roster
@@ -62,6 +59,8 @@ from meshbay_node.transport.webrtc_server import WebRTCTransport
from conftest import one_root
+TEST_GROUP = "g"
+
@pytest.fixture
def sk_node():