aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/tests/test_node_source_scope.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/tests/test_node_source_scope.py')
-rw-r--r--packages/meshbay-node/tests/test_node_source_scope.py35
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)