summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub')
-rw-r--r--packages/meshbay-hub/tests/node_tree.py16
-rw-r--r--packages/meshbay-hub/tests/test_helloworld_proves_the_plugin_claim.py6
2 files changed, 18 insertions, 4 deletions
diff --git a/packages/meshbay-hub/tests/node_tree.py b/packages/meshbay-hub/tests/node_tree.py
index 8704492..356bc81 100644
--- a/packages/meshbay-hub/tests/node_tree.py
+++ b/packages/meshbay-hub/tests/node_tree.py
@@ -52,3 +52,19 @@ def method(name: str) -> str:
found.append(ast.get_source_segment(text, member, padded=True))
assert len(found) == 1, f"{name}: expected one definition, found {len(found)}"
return found[0]
+
+
+def module_files(name: str) -> list[Path]:
+ """A node module by name — `ops.py`, or every file of the `ops/` package it
+ becomes — so a test reading it for an absence goes on reading all of it."""
+ src = TRANSPORT.parent
+ files = [src / f"{name}.py"] if (src / f"{name}.py").exists() else []
+ if (src / name).is_dir():
+ files += sorted(p for p in (src / name).rglob("*.py")
+ if "__pycache__" not in p.parts)
+ assert files, f"no module or package named {name} in the node"
+ return files
+
+
+def module_source(name: str) -> str:
+ return "\n".join(p.read_text(encoding="utf-8") for p in module_files(name))
diff --git a/packages/meshbay-hub/tests/test_helloworld_proves_the_plugin_claim.py b/packages/meshbay-hub/tests/test_helloworld_proves_the_plugin_claim.py
index 7fc9d8e..71a0ea8 100644
--- a/packages/meshbay-hub/tests/test_helloworld_proves_the_plugin_claim.py
+++ b/packages/meshbay-hub/tests/test_helloworld_proves_the_plugin_claim.py
@@ -35,8 +35,6 @@ import node_tree
import pytest
STATIC = Path(__file__).resolve().parents[1] / "src" / "meshbay_hub" / "static"
-NODE_SRC = (Path(__file__).resolve().parents[2] / "meshbay-node" / "src"
- / "meshbay_node")
APP = STATIC / "helloworld-app.js"
SETTINGS = STATIC / "helloworld-app-settings.js"
@@ -69,14 +67,14 @@ def test_no_shared_client_file_mentions_it(name):
@pytest.mark.parametrize("name", [
- "ops.py", "roster.py", "config.py", "roots.py",
+ "ops", "roster", "config", "roots",
])
def test_no_shared_node_module_mentions_it(name):
"""
Its directories are stored by `ops.set_app_directories`, which keys the row
by whatever the app is called. Nothing on the node knows what it is.
"""
- source = (NODE_SRC / name).read_text(encoding="utf-8")
+ source = node_tree.module_source(name)
assert "helloworld" not in source.lower(), (
f"{name} names the reference app; the generic path was supposed to "
f"cover it")