diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-23 22:25:28 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-24 16:45:37 +0200 |
| commit | 328b01a2dd545d70a078db8df1e91b02d65bfc9c (patch) | |
| tree | 9af69d617d9482ba4256f3d7334c9dd6cde0d5e2 /packages/meshbay-node/tests/test_node_source_scope.py | |
| parent | 92ea222b7aca6a3eb5f04330f0af6755e6e434e3 (diff) | |
| download | meshbay-328b01a2dd545d70a078db8df1e91b02d65bfc9c.tar.gz | |
test: read the WebRTC transport's source as a set of files
Source-reading tests take their text from node_source (node) and node_tree
(hub): webrtc_server.py plus anything under transport/webrtc/, so a check
for something's absence keeps reading the code it guards if that code moves.
test_node_source_scope holds the boundary.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests/test_node_source_scope.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_node_source_scope.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_node_source_scope.py b/packages/meshbay-node/tests/test_node_source_scope.py new file mode 100644 index 0000000..e5a86ff --- /dev/null +++ b/packages/meshbay-node/tests/test_node_source_scope.py @@ -0,0 +1,35 @@ +""" +The file set `node_source` hands to the source-reading tests has to contain +the code those tests are about. + +It is derived from the tree — `webrtc_server.py` and everything under +`transport/webrtc/` — so that a module split out later is read without anybody +adding it to a list. That only holds while the code actually lives there: a +class the session is built from, put anywhere else, would leave every +"nothing here does X" test in this suite silently not reading it. +""" + +import inspect +from pathlib import Path + +from meshbay_node.transport.webrtc_server import WebRTCPeerSession, WebRTCTransport +from node_source import TRANSPORT, webrtc_files + + +def test_every_class_the_transport_is_built_from_is_in_scope(): + scope = {p.resolve() for p in webrtc_files()} + for cls in (WebRTCPeerSession, WebRTCTransport): + for klass in cls.__mro__: + if not klass.__module__.startswith("meshbay_node."): + continue + where = Path(inspect.getsourcefile(klass)).resolve() + assert where in scope, ( + f"{klass.__qualname__} ({cls.__name__}) is defined in " + f"{where.relative_to(TRANSPORT.parent)}, which the source-reading " + f"tests do not read — move it under transport/webrtc/") + + +def test_the_scope_is_not_empty(): + files = webrtc_files() + assert TRANSPORT / "webrtc_server.py" in files + assert all(p.exists() for p in files) |